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

Phpstan Incorrectly Decides "If Condition is Always True" #8625

Closed
oleibman opened this issue Jan 2, 2023 · 3 comments
Closed

Phpstan Incorrectly Decides "If Condition is Always True" #8625

oleibman opened this issue Jan 2, 2023 · 3 comments

Comments

@oleibman
Copy link

oleibman commented Jan 2, 2023

Bug report

This error is new with PhpStan 1.9.4. It was handled correctly with 1.9.2.

We assign a boolean to false, and invert it on every iteration of a loop. PhpStan nevertheless decides it is always true.

Code snippet that reproduces the problem

https://phpstan.org/r/89bb3bd7-fad3-403e-8853-116078dfb44f

Expected output

No errors.

PhpStan reports that the condition is always true. It is incorrect. Demo, if needed, is at https://onlinephp.io?s=dZDBasMwDIbPDuQdRMkhgV7a3ZKF0VvfoIetFM9ViJiJjeUUwti7V3Yp6WVgS_Dr0wf2-4cfPVzRWB2w5hjIxEtcPDL0sGu6sigLmTHDEa11JxfstSx-y0L5-duSAY46ShvmyURyE7BeMlk3LdwcCawSraofXEQ5aMvY5cA65w8h6BR_7raw38LbOY8GF1CbEeoXRjNU1EB2PWWP1r9aFQ2yJvkTVWhGBxvqK4KEE0MMM35Nmwf_Byi7_8NZvdKppiJXzvonbbs-vLsD&v=7.3.33%2C8.1.7%2C8.0.20%2C7.4.30

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

I am usually very happy with PhpStan. Not today, I'm afraid - hopefully just a minor aberration.

@herndlm
Copy link
Contributor

herndlm commented Jan 2, 2023

Jfyi, this could be the same or very related to #8621

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src@cde53d1

@github-actions
Copy link

github-actions bot commented Feb 4, 2023

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants