-
-
Notifications
You must be signed in to change notification settings - Fork 868
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
Flipping a bool not detected #10566
Comments
The problem is that PHPStan does not understand the closure is immediately called and the outer scope should be invalidated. If we call A discussion I had earlier today is highly relevant to this: #10565 (comment) (We should have more information about what happens to a passed closure, it would be easier to analyse code with this information.) |
It's sadly a bit more complicated than that, mainly made it simpler to show the issue. If you call it after the
If we could provide a callable MIGHT call stop that would help. |
What's your expected output for https://phpstan.org/r/8c849f4a-e1bc-4de1-bfa1-435202622159? I think it's correct. You're breaking inside the |
Good point, you are right it is correct because it's 100% guaranteed to be called. However, if you add uncertainty to the mix it still reports the same error: https://phpstan.org/r/62cd712d-e2b4-4e26-92da-8338eecea1b2 |
I think the output is still correct? |
In this simple form, probably. Want me to create an example closer to the code? |
I haven't seen a real a PHPStan bug here so far so please do :) |
Added |
Fixed phpstan/phpstan-src#2980 |
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
The bool PHPStan isn't fully understanding is used to stop the loop, and it called in a (nested) handler. Somehow PHPStan doesn't get that. (Not sure how to best word this honestly.)
Code snippet that reproduces the problem
https://phpstan.org/r/71e8fa68-3cbd-4258-9632-00f3a8dca770
Expected output
No error reported on line 19
Did PHPStan help you today? Did it make you happy in any way?
No response
The text was updated successfully, but these errors were encountered: