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
Conditional while loop causes wrong assumption about array's contents #3314
Comments
@gmta After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
+4: While loop condition is always false.
7: Call to function in_array() with arguments '1', array<int, '1'> and true will always evaluate to true. Full report
|
Apparently PHPStan now understands that |
@gmta After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-7: Call to function in_array() with arguments '1', array<int, '1'> and true will always evaluate to true.
+No errors |
@gmta After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-7: Call to function in_array() with arguments '1', array<int, '1'> and true will always evaluate to true.
+4: While loop condition is always false. Full report
|
Fixed: phpstan/phpstan-src@4321374 |
Closes phpstan/phpstan#5759 Closes phpstan/phpstan#5668 Closes phpstan/phpstan#5496 Closes phpstan/phpstan#4666 Closes phpstan/phpstan#3892 Closes phpstan/phpstan#3314 Closes phpstan/phpstan#2870 Closes phpstan/phpstan#5354
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. |
Code snippet that reproduces the problem
https://phpstan.org/r/49a3d04d-8e39-4420-b0cd-66a0db7fa541
Old example: https://phpstan.org/r/0eededac-4378-4914-8928-ce5cb34cba85
Problem
The fact that the contents of the
while
block is never executed is not taken into account, leading PHPStan to incorrectly conclude that the first entry of the array is always present and has a constant value.Still an issue as of PHPStan version 0.12.28.
The text was updated successfully, but these errors were encountered: