Skip to content

Commit d2aa5a7

Browse files
committed
Use isAlwaysTerminating of finalScopeResult and update test
1 parent 2c81f7a commit d2aa5a7

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
@@ -1413,8 +1413,10 @@ private function processStmtNode(
14131413

14141414
if ($alwaysIterates) {
14151415
$isAlwaysTerminating = count($finalScopeResult->getExitPointsByType(Break_::class)) === 0;
1416+
} elseif ($isIterableAtLeastOnce->yes()) {
1417+
$isAlwaysTerminating = $finalScopeResult->isAlwaysTerminating();
14161418
} else {
1417-
$isAlwaysTerminating = false; // $finalScopeResult->isAlwaysTerminating() && $isAlwaysIterable
1419+
$isAlwaysTerminating = false;
14181420
}
14191421

14201422
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)