Skip to content

Routing typed array through array_map loses its types (?) #4587

@simPod

Description

@simPod

Bug report

I typed a list. Then passed it into array_map(). The return type of array map is not inferred correctly.

Method HelloWorld::a() should return iterable<array('a' => int)> but returns array<int, array>.

Method HelloWorld::b() should return iterable<array('a' => string)> but returns array<int, array&nonEmpty>.

Error message is not helping much here.

Code snippet that reproduces the problem

https://phpstan.org/r/7209aa2b-9f31-4db0-b7f7-c820c052bfbd

Expected output

No errors. I even think that typing the inner callable might not be necessary? Not sure about that.

https://phpstan.org/r/f6ddc282-c116-44ee-8d92-9e6f599815de

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions