mirror of
https://github.com/danog/psalm.git
synced 2024-12-12 09:19:40 +01:00
Merge pull request #6390 from orklah/templateGenerator
fix Generator giving templates to Iterator
This commit is contained in:
commit
4b3d02f8cb
@ -12,6 +12,7 @@ use Psalm\Type\Union;
|
||||
use function array_merge;
|
||||
use function array_values;
|
||||
use function count;
|
||||
use function is_a;
|
||||
use function reset;
|
||||
use function strpos;
|
||||
use function substr;
|
||||
@ -483,6 +484,12 @@ class TemplateStandinTypeReplacer
|
||||
$atomic_input_type->as
|
||||
)
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_a($input_key, $key, true)) {
|
||||
$matching_atomic_types[$atomic_input_type->getId()] = $atomic_input_type;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -270,6 +270,22 @@ class GeneratorTest extends TestCase
|
||||
[],
|
||||
['UndefinedClass']
|
||||
],
|
||||
'fillTemplatesForIteratorFromGenerator' => [
|
||||
'<?php
|
||||
/**
|
||||
* @return Generator<int, string>
|
||||
*/
|
||||
function generator(): Generator
|
||||
{
|
||||
yield "test";
|
||||
}
|
||||
|
||||
$iterator = new NoRewindIterator(generator());
|
||||
',
|
||||
'assertions' => [
|
||||
'$iterator' => 'NoRewindIterator<int, string>',
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user