Skip to content

match on count(...) could narrow array type #10974

@RobertMe

Description

@RobertMe

Feature request

It would be nice if a match(count($array)) would narrow the type $array to non-empty-array for any cases which aren't 0.

See this example: https://phpstan.org/r/d7a823e1-d74d-4544-b282-9bab5d449198
When using if / else it properly knows that the $array can't be empty anymore, but when using match(count(...)) that's not the case.

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

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions