diff --git a/src/Analyser/StmtHandler/ForHandler.php b/src/Analyser/StmtHandler/ForHandler.php index e59ec2e5d15..6d14dd3e1f1 100644 --- a/src/Analyser/StmtHandler/ForHandler.php +++ b/src/Analyser/StmtHandler/ForHandler.php @@ -221,8 +221,14 @@ public function processStmt( $passFlows[] = $bodyScopeResult->getVariableFlow(); $backEdgeScope = $bodyScopeResult->getLoopBackEdgeScope(); if ($backEdgeScope === null) { - $bodyScope = $prevScope; - break; + if ($nodeScopeResolver->isReplayableConvergenceBody($stmt, $stmt->stmts)) { + $bodyScope = $prevScope; + break; + } + // a nested loop is walked only once in deep context, so the + // back edge it would reach on a later iteration can look dead - + // continue from the end of the body instead of stopping here + $backEdgeScope = $bodyScopeResult->getScope(); } $bodyScope = $backEdgeScope; diff --git a/src/Turbo/TurboExtensionEnabler.php b/src/Turbo/TurboExtensionEnabler.php index 374d29043e6..90dd54da5cd 100644 --- a/src/Turbo/TurboExtensionEnabler.php +++ b/src/Turbo/TurboExtensionEnabler.php @@ -33,7 +33,7 @@ final class TurboExtensionEnabler { - public const EXPECTED_EXTENSION_VERSION = 'a0f7086'; + public const EXPECTED_EXTENSION_VERSION = '6f46059'; private static bool $active = false; diff --git a/tests/PHPStan/Rules/Comparison/NumberComparisonOperatorsConstantConditionRuleTest.php b/tests/PHPStan/Rules/Comparison/NumberComparisonOperatorsConstantConditionRuleTest.php index 106ddee426d..ccc7e32fe7e 100644 --- a/tests/PHPStan/Rules/Comparison/NumberComparisonOperatorsConstantConditionRuleTest.php +++ b/tests/PHPStan/Rules/Comparison/NumberComparisonOperatorsConstantConditionRuleTest.php @@ -327,6 +327,11 @@ public function testBug15243(): void $this->analyse([__DIR__ . '/../../Analyser/nsrt/bug-15243.php'], []); } + public function testBug15420(): void + { + $this->analyse([__DIR__ . '/data/bug-15420.php'], []); + } + public function testShiftLeftUnboundedRange(): void { $this->analyse([__DIR__ . '/../../Analyser/nsrt/shift-left-unbounded-range.php'], []); diff --git a/tests/PHPStan/Rules/Comparison/data/bug-15420.php b/tests/PHPStan/Rules/Comparison/data/bug-15420.php new file mode 100644 index 00000000000..503b65adfb4 --- /dev/null +++ b/tests/PHPStan/Rules/Comparison/data/bug-15420.php @@ -0,0 +1,26 @@ +