Skip to content

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

@oleibman

Description

@oleibman

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions