Skip to content

False positive when using match expression to narrow types #9694

@axlon

Description

@axlon

Bug report

It appears that PHPStan doesn't narrow types that are part of a match expression's condition, which leads to false positives when a match expression is used to eliminate certain types from a union.

Code snippet that reproduces the problem

https://phpstan.org/r/1b12aa5c-1398-4065-a014-80cfe3c45916

Expected output

No errors. We already know that the object cannot be null because we ended up in the false match arm.

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

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions