Skip to content

uncaught TypeError when calling array_map with null callback and non-empty array #8806

@frontenac

Description

@frontenac

The following works in 4.30 but throws a TypeError in 5.0

array_map(null, [1]);

https://psalm.dev/r/fd479a295e

Internal Psalm error on line 101 - /vendor/vimeo/psalm/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMapReturnTypeProvider.php: Psalm\Internal\Provider\ReturnTypeProvider\ArrayMapReturnTypeProvider::Psalm\Internal\Provider\ReturnTypeProvider\{closure}(): Argument #1 ($sub) must be of type array, Psalm\Type\Union given

array_map(null, []); runs without exception.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions