Skip to content

Switch does not pass argument type upon match with nullable type #2384

@rbairwell

Description

@rbairwell

Bug report

Local version: 0.11.15

When a switch statement is in place where the switch variable is a nullable type and the case detects a string value, PHPStan fails to recognise that the variable then passed to subfunctions from the case are of the the type string (it believes the variable is still nullable).

Code snippet that reproduces the problem

: https://phpstan.org/r/5b0a624a-e337-43db-ac10-d97a77b697da

Expected output

No error reported.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions