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

Setting property in anonymous function is ignored by if.alwaysFalse #10903

Open
felixkempf opened this issue Apr 18, 2024 · 0 comments
Open

Setting property in anonymous function is ignored by if.alwaysFalse #10903

felixkempf opened this issue Apr 18, 2024 · 0 comments
Labels
Milestone

Comments

@felixkempf
Copy link

Bug report

Conditionally setting a bool property to true in an anonymous function is seemingly ignored and afterwards, the property is reported as if.alwaysFalse.

The linked playground code is a heavily simplified example, that might seem unnecessarily complicated for what it does.
Please don't suggest how I could achieve this with simpler code.

I want to know whether this is a genuine limitation of PHPStan that I simply have to ignore (for example with baseline) or a bug.

Code snippet that reproduces the problem

https://phpstan.org/r/34645b2b-7911-4a98-8fa2-67e5e73a9868

Expected output

Ideally PHPStan should detect no error, as the property in the given example is definitely true

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

I love how rapidly I can crunch through the PHPStan errors with PHPStan Pro after increasing the level and how I always find some weird bug or oversight in code that was not touched in years

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants