Skip to content

array_keys() with filter treated as non-empty array after not empty source array check #13377

@jdevinemt

Description

@jdevinemt

Bug report

When an array is checked to be not empty, subsequent results from array_keys() with that array as the $array argument and a $filter argument provided are assumed to be not empty. This is not a valid assumption because the result could be empty after being filtered. Occurs on level 4+.

See the attached snippet.

Code snippet that reproduces the problem

https://phpstan.org/r/1adc9aae-0f5a-4e5e-85e7-c5c17e21038e

Expected output

No issues reported.

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

Definitely. I love this tool. This is the only odd result I've experienced during a cleanup of thousands of files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions