Skip to content

"$variable might not be defined" errors when using exhaustive if statements with constant enums #5266

@ekisu

Description

@ekisu

Bug report

When using constant enums on function parameters, variables that are declared inside an exhaustive if statement are reported as might not be defined, even though it's certainly defined.

Code snippet that reproduces the problem

https://phpstan.org/r/4a1aeeb3-758f-4dc9-99ab-dee8055071c6

Expected output

There should be no error reported, as every case of the constant enum is covered by the if statement, and every branch of the if statement declares the $message variable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions