Skip to content
2 changes: 1 addition & 1 deletion src/Analyser/NodeScopeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ private function processStmtNode(

return new StatementResult(
$finalScope,
$finalScopeResult->hasYield(),
$finalScopeResult->hasYield() || $condResult->hasYield(),
$isAlwaysTerminating,
[]
);
Expand Down
6 changes: 6 additions & 0 deletions tests/PHPStan/Rules/Missing/data/missing-return.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,12 @@ public function bodySpecifiedVoidTReturn3(): \Generator
return 2;
}

public function yieldInExpression(): \Generator
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue reported was detected by the MissingReturn rule. Not sure if there is a more suitable way to test (the test is that there is no error).

{
while($foo = yield 'foo') {
}
}

}

class VoidUnion
Expand Down