Skip to content

array_map Ignores callable return type #5314

@danielbeardsley

Description

@danielbeardsley

Problem

Psalm usually understands how array_map works but we've found a case where it doesn't and it's pretty weird.
Psalm understands the closure returns a stdClass (as seen in the trace) but array mapping over that closure results in array<mixed>.

https://psalm.dev/r/4c414bde70

It's particularly weird that if I include a @var annotation of exactly what the trace is telling me, psalm both tells me the annotation is redundant AND that the array map now returns the expected array<stdClass>.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions