1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 12:55:26 +01:00

Merge pull request #6790 from orklah/fix_yield

This commit is contained in:
Bruce Weirdan 2021-11-01 20:25:54 +02:00 committed by GitHub
commit 81ca05f3ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -343,7 +343,8 @@ class ReturnTypeCollector
if ($stmt instanceof PhpParser\Node\Expr\MethodCall
|| $stmt instanceof PhpParser\Node\Expr\FuncCall
|| $stmt instanceof PhpParser\Node\Expr\StaticCall) {
|| $stmt instanceof PhpParser\Node\Expr\StaticCall
|| $stmt instanceof PhpParser\Node\Expr\New_) {
$yield_types = [];
foreach ($stmt->getArgs() as $arg) {

View File

@ -286,6 +286,15 @@ class GeneratorTest extends TestCase
'$iterator' => 'NoRewindIterator<int, string>',
]
],
'detectYieldInNew' => [
'<?php
/** @psalm-suppress MissingClosureReturnType */
$_a = function() { return new RuntimeException(yield "a"); };
',
'assertions' => [
'$_a' => 'pure-Closure():Generator<int, "a", mixed, RuntimeException>',
]
],
];
}