1
0
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:
Brown 2019-01-31 17:58:53 -05:00
parent fd88f00526
commit c5a0a3df86
2 changed files with 14 additions and 1 deletions

View File

@ -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();

View File

@ -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;
}',
],
];
}