-
-
Notifications
You must be signed in to change notification settings - Fork 863
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
Type narrowing should be undone after assignment/modification #5129
Comments
@Seldaek After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
5: Property HelloWorld::$foo has no typehint specified.
+10: Comparison operation ">" between 0 and 0 is always false.
15: Comparison operation ">" between 0 and 0 is always false. Full report
|
Updated snippet because it doesn't really seem like things improved :) https://phpstan.org/r/77218913-41c8-4d15-8a46-b9e03a49c221 it appears with dumptype that the type has changed after being assigned 'x', but the error at line 17 makes no sense to me. |
The bot message didn't say it was fixed, it was related to PHPStan being more smart about But your message sparked off an idea in my head that this really isn't that hard to fix it, and it worked on the first try :) So it's fixed: phpstan/phpstan-src@4220e43 |
Ok that looks great, thanks! |
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. |
Bug report
If a type is narrowed but then the variable changes, it is detected correctly with local variables, but with object properties it does not seem to be the case.
Code snippet that reproduces the problem
https://phpstan.org/r/9aac1f93-cbcc-497d-bd75-79e224ac4838
Expected output
No error
Did PHPStan help you today? Did it make you happy in any way?
Yes yes, cleaning things up :)
The text was updated successfully, but these errors were encountered: