Skip to content

Commit

Permalink
Merge pull request #6790 from orklah/fix_yield
Browse files Browse the repository at this point in the history
  • Loading branch information
weirdan committed Nov 1, 2021
2 parents ea5b9bb + c5c779c commit 81ca05f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Expand Up @@ -343,7 +343,8 @@ protected static function getYieldTypeFromExpression(

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) {
Expand Down
9 changes: 9 additions & 0 deletions tests/GeneratorTest.php
Expand Up @@ -286,6 +286,15 @@ function generator(): Generator
'$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>',
]
],
];
}

Expand Down

0 comments on commit 81ca05f

Please sign in to comment.