Thanks to visit codestin.com
Credit goes to github.com

Skip to content

TypeSpecifyingFunctions in conditionals work for switch and if, but not match #10585

@patrickkusebauch

Description

@patrickkusebauch

Bug report

If you have a match statement over a TypeSpecifying function, it does not correctly infer the type for each branch, as it does for switch or if statement. If it was missing everywhere, I would consider this a feature request, but as the behavior is not consistent across branching expressions, looks more like a bug to me.

Code snippet that reproduces the problem

https://phpstan.org/r/71638a26-f248-4b00-a161-7c6eb78ff75d

Expected output

Dumped type for match branches is not a union but the specified types, as is the case for if and switch.

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