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_a is not correctly removing class-string type in a falsey scope #6704

Closed
herndlm opened this issue Feb 27, 2022 · 1 comment · Fixed by phpstan/phpstan-src#1040
Closed
Labels

Comments

@herndlm
Copy link
Contributor

herndlm commented Feb 27, 2022

Bug report

Sorry, digging up another weird exotic edge case here.. In general is_a is working quite well, but there are problems with class-string types in a falsey scope only. Object types in a falsey scope work just fine.

As is_subclass_of works really similar and both of them have type specyfing extensions, I assume there could be similar problems there. So maybe something found via https://github.com/phpstan/phpstan/issues?q=is%3Aissue+is%3Aopen+is_subclass_of is related

Maybe phpstan/phpstan-src#1039 is related too and we can take over adaptions from there. I did not thoroughly check yet tbh.

I'm happy to try fixing this myself later.

Code snippet that reproduces the problem

https://phpstan.org/r/6823a8c6-a4f2-456b-a7d5-995b70feef2d

Expected output

No errors.

Did PHPStan help you today? Did it make you happy in any way?

Initially I thought there are more problems with is_a, then I figured out I was testing wrong and PHPStan outsmarted me again ;)

@github-actions
Copy link

github-actions bot commented Apr 1, 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 Apr 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants