Skip to content

Avoid false error on is_subclass_of#4472

Open
VincentLanglet wants to merge 4 commits intophpstan:2.1.xfrom
VincentLanglet:isSubClass
Open

Avoid false error on is_subclass_of#4472
VincentLanglet wants to merge 4 commits intophpstan:2.1.xfrom
VincentLanglet:isSubClass

Conversation

@VincentLanglet
Copy link
Contributor

@VincentLanglet VincentLanglet commented Oct 23, 2025

@VincentLanglet VincentLanglet marked this pull request as ready for review October 24, 2025 17:33
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@VincentLanglet
Copy link
Contributor Author

This issue was more complicated than expected... I'm not against your opinion/review @staabm :)

@VincentLanglet VincentLanglet requested a review from staabm October 29, 2025 21:49
@VincentLanglet VincentLanglet requested a review from staabm October 31, 2025 15:32
@VincentLanglet VincentLanglet force-pushed the isSubClass branch 2 times, most recently from 5aab962 to b37f439 Compare December 5, 2025 15:28
@VincentLanglet
Copy link
Contributor Author

I dunno what to do about the webmozart-assert failure because I don't report anymore

Call to static method Webmozart\Assert\Assert::implementsInterface() with class-string<WebmozartAssertImpossibleCheck\Bar>|WebmozartAssertImpossibleCheck\Bar and 'WebmozartAssertImpossibleCheck\\Bar' will always evaluate to true.

Technically, because a implementsInterface check is called before it's indeed always true.
But strictly looking at the type, calling

class-string<WebmozartAssertImpossibleCheck\Bar>|WebmozartAssertImpossibleCheck\Bar

And currently, phpstan/phpstan-webmozart-assert#194 is showing the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PHPStan incorrectly narrows type of object after an instanceof check

3 participants