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:
parent
640ffdb324
commit
75761647c2
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user