Skip to content

Commit ad2f7d1

Browse files
committed
Use isAlwaysTerminating of finalScopeResult and update test
1 parent 19296c5 commit ad2f7d1

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/Analyser/NodeScopeResolver.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1414,8 +1414,10 @@ private function processStmtNode(
14141414

14151415
if ($alwaysIterates) {
14161416
$isAlwaysTerminating = count($finalScopeResult->getExitPointsByType(Break_::class)) === 0;
1417+
} elseif ($isIterableAtLeastOnce->yes()) {
1418+
$isAlwaysTerminating = $finalScopeResult->isAlwaysTerminating();
14171419
} else {
1418-
$isAlwaysTerminating = false; // $finalScopeResult->isAlwaysTerminating() && $isAlwaysIterable
1420+
$isAlwaysTerminating = false;
14191421
}
14201422

14211423
return new StatementResult(

tests/PHPStan/Analyser/StatementResultTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ public function dataIsAlwaysTerminating(): array
243243
],
244244
[
245245
'for ($i = 0; $i < 10; $i++) { return; }',
246-
false, // will be true with range types
246+
true,
247247
],
248248
[
249249
'for ($i = 0; $i < 0; $i++) { return; }',

0 commit comments

Comments
 (0)