mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Fix yielding from iterable
This commit is contained in:
parent
fd88f00526
commit
c5a0a3df86
@ -224,7 +224,10 @@ class ReturnTypeCollector
|
||||
$value_type = null;
|
||||
|
||||
foreach ($yield_types as $type) {
|
||||
if ($type instanceof Type\Atomic\TArray || $type instanceof Type\Atomic\TGenericObject) {
|
||||
if ($type instanceof Type\Atomic\TArray
|
||||
|| $type instanceof Type\Atomic\TIterable
|
||||
|| $type instanceof Type\Atomic\TGenericObject
|
||||
) {
|
||||
switch (count($type->type_params)) {
|
||||
case 1:
|
||||
$key_type_param = Type::getMixed();
|
||||
|
@ -330,6 +330,16 @@ class Php70Test extends TestCase
|
||||
return null;
|
||||
}',
|
||||
],
|
||||
'yieldFromIterable' => [
|
||||
'<?php
|
||||
/**
|
||||
* @param iterable<int, string> $s
|
||||
* @return Generator<int, string>
|
||||
*/
|
||||
function foo(iterable $s) : Traversable {
|
||||
yield from $s;
|
||||
}',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user