Skip to content

Support string callables via array_filter #6417

@herndlm

Description

@herndlm

Feature request

array_filter is already understanding complex closures or arrow functions via ArrayFilterFunctionReturnTypeReturnTypeExtension but interestingly it can't deal with more simple string-callables like is_string. Would be great if it could understand that as well.

It looks like TypeSpecifyingFunctionsDynamicReturnTypeExtension is dealing with the narrowing-down of those simple type specifying functions and therefore maybe somehow related.

See https://phpstan.org/r/33b86b4b-41ae-4953-b062-80d11a74ffb2

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

Yes for sure. And I was impressed that it can narrow down arrays to lists via $a === array_values($a) :)

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