Skip to content
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

is_subclass_of(string, string) generates invalid prediction #3979

Open
thg2k opened this issue Oct 21, 2020 · 8 comments
Open

is_subclass_of(string, string) generates invalid prediction #3979

thg2k opened this issue Oct 21, 2020 · 8 comments
Labels
Milestone

Comments

@thg2k
Copy link

thg2k commented Oct 21, 2020

Bug report

Erroneus report: Result of && is always false

Clearly that is not correct as demonstrated by the two calls below.

Code snippet that reproduces the problem

https://phpstan.org/r/99bd746d-80c2-4eb1-8506-2840c6fd5089

Expected output

No errors.

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Oct 21, 2020
@vovmog
Copy link

vovmog commented Apr 30, 2021

@phpstan-bot
Copy link
Contributor

@vovmog After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
-21: Call to an undefined method object::toArray().
+No errors

@enumag
Copy link
Contributor

enumag commented Feb 28, 2022

It seems this was also fixed by phpstan/phpstan-src#1039.

@ondrejmirtes
Copy link
Member

ondrejmirtes commented Feb 28, 2022

Fixed: phpstan/phpstan-src@73f14db

@ondrejmirtes
Copy link
Member

The first example still reports an error.

@ondrejmirtes
Copy link
Member

This gives more insight into the types involved: https://phpstan.org/r/4399bb2a-cf2b-4038-9716-97cac1e647d4

@VincentLanglet
Copy link
Contributor

VincentLanglet commented Jan 23, 2023

This can be simplified to https://phpstan.org/r/2b8bb6fd-da7d-4f2c-9318-246cf0ce29a1

is_subclass_of(class-string, string) is always true for PHPStan

I would have expected to find a DynamicReturnTypeExtension, but all I found is IsSubclassOfFunctionTypeSpecifyingExtension. I never worked with TypeSpecifyingExtension but to me it's supposed to determine the type of the parameter based on the return type ; and not the opposite...

@mvorisek
Copy link
Contributor

would ge great if this count be fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants