Skip to content

Commit ec2d94e

Browse files
committed
Revert "Fix while loop inside another loop during scope stabilization phase"
This reverts commit 94b6012.
1 parent e4eae3b commit ec2d94e

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

src/Analyser/NodeScopeResolver.php

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,22 +1282,6 @@ private function processStmtNode(
12821282
} elseif ($stmt instanceof While_) {
12831283
$condResult = $this->processExprNode($stmt, $stmt->cond, $scope, static function (): void {
12841284
}, ExpressionContext::createDeep(), $context);
1285-
$beforeCondBooleanType = ($this->treatPhpDocTypesAsCertain ? $scope->getType($stmt->cond) : $scope->getNativeType($stmt->cond))->toBoolean();
1286-
$condScope = $condResult->getFalseyScope();
1287-
if (!$context->isTopLevel() && $beforeCondBooleanType->isFalse()->yes()) {
1288-
if (!$this->polluteScopeWithLoopInitialAssignments) {
1289-
$scope = $condScope->mergeWith($scope);
1290-
}
1291-
1292-
return new StatementResult(
1293-
$scope,
1294-
$condResult->hasYield(),
1295-
false,
1296-
[],
1297-
$condResult->getThrowPoints(),
1298-
$condResult->getImpurePoints(),
1299-
);
1300-
}
13011285
$bodyScope = $condResult->getTruthyScope();
13021286

13031287
if ($context->isTopLevel()) {
@@ -1344,6 +1328,7 @@ private function processStmtNode(
13441328
$finalScope = $finalScope->mergeWith($breakExitPoint->getScope());
13451329
}
13461330

1331+
$beforeCondBooleanType = ($this->treatPhpDocTypesAsCertain ? $scope->getType($stmt->cond) : $scope->getNativeType($stmt->cond))->toBoolean();
13471332
$isIterableAtLeastOnce = $beforeCondBooleanType->isTrue()->yes();
13481333
$nodeCallback(new BreaklessWhileLoopNode($stmt, $finalScopeResult->getExitPoints()), $bodyScopeMaybeRan);
13491334

@@ -1354,7 +1339,7 @@ private function processStmtNode(
13541339
} else {
13551340
$isAlwaysTerminating = false;
13561341
}
1357-
1342+
$condScope = $condResult->getFalseyScope();
13581343
if (!$isIterableAtLeastOnce) {
13591344
if (!$this->polluteScopeWithLoopInitialAssignments) {
13601345
$condScope = $condScope->mergeWith($scope);

0 commit comments

Comments
 (0)