Skip to content

Return type of array_filter() unexpectedly nullable? #12689

@adnweedon

Description

@adnweedon

Bug report

This was originally reported at rectorphp/rector#9045

When array_filter has a mixed type input, PHPStan thinks that it can return a nullable array, when array_filter only ever returns a strict array according to https://www.php.net/manual/en/function.array-filter.php and the signature within phpstan-src.

Code snippet that reproduces the problem

https://phpstan.org/r/3f0d0348-dd07-42cb-b598-1b2297e3dd4e

Expected output

I expected the dumped type to just be array, not including null.

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

PHPStan is great - both as a project in its own right, and when extended by other things like Rector, thanks for all your hard work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions