Skip to content

No checks for array_map closure params #1954

@muglug

Description

@muglug
<?php declare(strict_types = 1);

$a = [1, new stdClass()];
$b = array_map(function (string $s) : string { return $s; }, $a);

Expected: argument passed to first arg of array_map is wrong
Actual: No issues

https://phpstan.org/r/15291a0f-d267-4eec-87d3-61ef0803df57

Would have flagged this code:

$actualErrors = array_map(
static function (Error $error): string {
return sprintf('%02d: %s', $error->getLine(), $error->getMessage());
},
$actualErrors
);

which expects is passed string[]|\PHPStan\Analyser\Error[]

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