Skip to content

if (with assignment to existing variable and type checking) is always false #2499

@yura3d

Description

@yura3d

Bug report

If I declare a variable and set a value of some type to it (let it be int, like in code snippet), change its value (mixed in snippet) in if statement and check the variable to be another type (string in snippet) in the same if statement, I get "If condition is always false".

Code snippet that reproduces the problem

https://phpstan.org/r/884e2c78-c95c-46f8-8a01-0d990cddee0a

Expected output

No errors, like it works when the variable is not declared before if statement

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions