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
Incorrect variable may not be defined #1865
Comments
Hi, this is very analyser-unfriendly code. It wouldn't work in other languages either. I group similar issues here: https://github.com/phpstan/phpstan/milestone/12 The main problem is that the value of I usually solve this with an |
If extract() is not used in whole (analyzed) code and the variable is not passed to any other function (and even if it is passed, the analyzer should know if it is by reference) and not modified in code, the false positive error could be suppressed. I think that could cover more than 95%. |
Implemented: phpstan/phpstan-src@54284c8 |
phpstan/phpstan-src@f760583 Regression test for bug #1865
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. |
Summary of a problem or a feature request
"Variable $key might not be defined." reported incorrectly. The $key variable is a scalar bool value (not a reference) and it is assigned only once.
Code snippet that reproduces the problem
https://phpstan.org/r/a8eba03f-946a-426f-90af-7575659a6a9e
Expected output
Do not report this.
The text was updated successfully, but these errors were encountered: