mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Fix #1240 - reconcile array to iterable in template replacement
This commit is contained in:
parent
c0f3197790
commit
bed1f15e09
@ -913,6 +913,11 @@ class Union
|
||||
break;
|
||||
}
|
||||
|
||||
if ($input_key === 'array' && $key === 'iterable') {
|
||||
$matching_atomic_type = $atomic_input_type;
|
||||
break;
|
||||
}
|
||||
|
||||
if (strpos($input_key, $key . '&') === 0) {
|
||||
$matching_atomic_type = $atomic_input_type;
|
||||
break;
|
||||
|
@ -2033,6 +2033,22 @@ class TemplateTest extends TestCase
|
||||
*/
|
||||
class SomeRepository extends Repository {}'
|
||||
],
|
||||
'upcastArrayToIterable' => [
|
||||
'<?php
|
||||
/**
|
||||
* @template K
|
||||
* @template V
|
||||
* @param iterable<K,V> $collection
|
||||
* @return V
|
||||
* @psalm-suppress InvalidReturnType
|
||||
*/
|
||||
function first($collection) {}
|
||||
|
||||
$one = first([1,2,3]);',
|
||||
[
|
||||
'$one' => 'int',
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user