Skip to content

Conditional else can cause inferred type to change #10422

@driskell

Description

@driskell

Bug report

It raises an error on $test->test(); saying that $test could be null.

Fairly easy to workaround but thought it was a curious case

Code snippet that reproduces the problem

https://phpstan.org/r/d3e1bc0e-ee7f-4f9e-9a9c-733d51dad43e

Expected output

No errors - $test to be not nullable at the point it has method called, regardless of the else condition or not

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

PHPStan probably saves me hours every day :smile

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions