Skip to content

Not null affectation does not define variable #4662

@alterphp

Description

@alterphp

Bug report

In a if statement, I first check that affectation of a variable is not NULL, and then try to use the variable in a second part of the condition. PHPStan output an error like Undefined variable: $affectedVar.

It could be related to #4357.

Code snippet that reproduces the problem

https://phpstan.org/r/43c76836-a07b-40ef-826f-e72c889b9024

Expected output

In the above example, PHPStan should not output that $programStartDate is undefined at line 22.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions