Skip to content

Issue with implementsInterface #150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
VincentLanglet opened this issue Oct 31, 2022 · 9 comments · Fixed by #151
Closed

Issue with implementsInterface #150

VincentLanglet opened this issue Oct 31, 2022 · 9 comments · Fixed by #151

Comments

@VincentLanglet
Copy link

With the following code

foreach ($data['sniffs'] as $sniffName) {
     Assert::string($sniffName);
     Assert::classExists($sniffName);
     Assert::implementsInterface($sniffName, SniffInterface::class);

     $ruleSet->addSniff(new $sniffName());
}

I get

Call to static method Webmozart\Assert\Assert::implementsInterface() with class-string and 'TwigCsFixer\\Sniff\\SniffInterface' will always evaluate to false.

i tried to install

"phpstan/phpstan": "1.9.x-dev as 1.9.0",
"phpstan/phpstan-webmozart-assert": "1.2.x-dev as 1.3",

but it doesn't solved anything

I saw you recently work on this method @herndlm (#144), any idea what could be wrong here ?

@herndlm
Copy link
Contributor

herndlm commented Oct 31, 2022

$data['sniffs'] is just mixed[] I presume?

@herndlm
Copy link
Contributor

herndlm commented Oct 31, 2022

ah wait, but my changes are still unreleased. that means most likely that https://github.com/phpstan/phpstan-webmozart-assert/blob/1.2.1/src/Type/WebMozartAssert/AssertTypeSpecifyingExtension.php#L454-L456 is the reason with the released version and, since you also get it with 1.2.x, subclassOf might be the problem afterwards. strange

I'll have to re-create this in a test and debug later.

@VincentLanglet
Copy link
Author

$data['sniffs'] is just mixed[] I presume?

Yes, I have previous checks

Assert::isArray($data);
Assert::keyExists($data, 'sniffs');
Assert::isArray($data['sniffs']);

ah wait, but my changes are still unreleased. that means most likely that https://github.com/phpstan/phpstan-webmozart-assert/blob/1.2.1/src/Type/WebMozartAssert/AssertTypeSpecifyingExtension.php#L454-L456 is the reason with the released version and, since you also get it with 1.2.x, subclassOf might be the problem afterwards. strange

I'll have to re-create this in a test and debug later.

Dunno if it help, but

Assert::isAOf($sniffName, SniffInterface::class);

is working fine

herndlm added a commit to herndlm/phpstan-webmozart-assert that referenced this issue Nov 2, 2022
@herndlm
Copy link
Contributor

herndlm commented Nov 2, 2022

interestingly my test cases are green here, can you check the linked PR if you do anything different or I missed anything? I'm both asserting types and doing the impossible checks with strict rules on 🤔

@VincentLanglet
Copy link
Author

@herndlm
Copy link
Contributor

herndlm commented Nov 2, 2022

I think this was fixed on develop. I know you wrote you tested it, but I could verify that it errors exactly like that if I revert a specific commit

@VincentLanglet
Copy link
Author

I think this was fixed on develop

I just tried again, and indeed I don't have the error with

        "phpstan/phpstan": "1.9.x-dev as 1.9.0",
        "phpstan/phpstan-webmozart-assert": "1.2.x-dev as 1.2.2",

I dunno how I messed up the first time. Sorry for the inconvenient.

@herndlm
Copy link
Contributor

herndlm commented Nov 2, 2022

no worries, a double-check and another test case here don't hurt :)

ondrejmirtes pushed a commit that referenced this issue Nov 3, 2022
@github-actions
Copy link

github-actions bot commented Dec 4, 2022

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants