mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Don’t merge array and Traversable to iterable when there are intersections
This commit is contained in:
parent
d6f8a658bf
commit
0934988ec7
@ -261,6 +261,7 @@ class TypeCombination
|
||||
|| (isset($combination->named_object_types['Traversable'])
|
||||
&& $combination->named_object_types['Traversable']->from_docblock)
|
||||
)
|
||||
&& !$combination->extra_types
|
||||
) {
|
||||
$array_param_types = $combination->array_type_params;
|
||||
$traversable_param_types = $combination->builtin_type_params['Traversable']
|
||||
|
@ -964,6 +964,18 @@ class ArrayAccessTest extends TestCase
|
||||
}
|
||||
}'
|
||||
],
|
||||
'arrayAccessOnArraylikeObjectOrArray' => [
|
||||
'<?php
|
||||
/**
|
||||
* @param arraylike-object<int, string>|array<int, string> $arr
|
||||
*/
|
||||
function test($arr): string {
|
||||
return $arr[0] ?? "";
|
||||
}
|
||||
|
||||
test(["a", "b"]);
|
||||
test(new ArrayObject(["a", "b"]));'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user