1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Fix #3321 - allow interface methods to be mapped

This commit is contained in:
Brown 2020-05-08 14:52:53 -04:00
parent 640ffdb324
commit 75761647c2
2 changed files with 15 additions and 1 deletions

View File

@ -313,7 +313,7 @@ class ArrayMapReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnTyp
continue;
}
if (!$codebase->classlikes->classExists($callable_fq_class_name)) {
if (!$codebase->classlikes->classOrInterfaceExists($callable_fq_class_name)) {
continue;
}

View File

@ -1348,6 +1348,20 @@ class ArrayFunctionCallTest extends TestCase
$a = [42, "A" => 42];
echo array_change_key_case($a, CASE_LOWER)[0];'
],
'mapInterfaceMethod' => [
'<?php
interface MapperInterface {
public function map(string $s): int;
}
/**
* @param list<string> $strings
* @return list<int>
*/
function mapList(MapperInterface $m, array $strings): array {
return array_map([$m, "map"], $strings);
}'
],
];
}