Skip to content

False negative with nested if in for loop #4666

@nikophil

Description

@nikophil

Hello there,

Bug report

Here is an example of the problem.
https://phpstan.org/r/c499e9ad-92a3-47ec-91ba-42d0920dbc06

I got a false negative on this code. I know the code is far from ideal but it actually works, and moreover on the first iteration, the && result is definitely not false...

What's weird is that when you change the if in order to use CONST_2 in both part of the &&, phpstan returns 0 errors, although both parts of the && are unrelated. Or maybe i'm missing something Oo
If i split the && in order to use two nested if, I got no errors as well...

Expected output

no error should be reported.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions