Skip to content

Commit ef8206b

Browse files
dantleechondrejmirtes
authored andcommitted
Consider condition result hasYield ...
when determining if scope has yield or not.
1 parent 012ea82 commit ef8206b

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/Analyser/NodeScopeResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ private function processStmtNode(
867867

868868
return new StatementResult(
869869
$finalScope,
870-
$finalScopeResult->hasYield(),
870+
$finalScopeResult->hasYield() || $condResult->hasYield(),
871871
$isAlwaysTerminating,
872872
[]
873873
);

tests/PHPStan/Rules/Missing/data/missing-return.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,12 @@ public function bodySpecifiedVoidTReturn3(): \Generator
396396
return 2;
397397
}
398398

399+
public function yieldInExpression(): \Generator
400+
{
401+
while($foo = yield 'foo') {
402+
}
403+
}
404+
399405
}
400406

401407
class VoidUnion

0 commit comments

Comments
 (0)