1
0
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:
Bruce Weirdan 2021-09-02 23:14:17 +03:00 committed by GitHub
commit 4b3d02f8cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View File

@ -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;
}
}

View File

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