Skip to content

Commit d2d137e

Browse files
authored
Merge branch refs/heads/1.12.x into 2.0.x
2 parents 59ef891 + f2dfd5d commit d2d137e

File tree

8 files changed

+1
-356
lines changed

8 files changed

+1
-356
lines changed

src/Analyser/MutatingScope.php

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -4865,68 +4865,6 @@ public function processAlwaysIterableForeachScopeWithoutPollute(self $finalScope
48654865
);
48664866
}
48674867

4868-
public function processAlwaysIterableForScopeWithoutPollute(self $finalScope, self $initScope): self
4869-
{
4870-
$expressionTypes = $this->expressionTypes;
4871-
$initScopeExpressionTypes = $initScope->expressionTypes;
4872-
foreach ($finalScope->expressionTypes as $variableExprString => $variableTypeHolder) {
4873-
if (!isset($expressionTypes[$variableExprString])) {
4874-
if (isset($initScopeExpressionTypes[$variableExprString])) {
4875-
$expressionTypes[$variableExprString] = ExpressionTypeHolder::createMaybe($variableTypeHolder->getExpr(), $variableTypeHolder->getType());
4876-
continue;
4877-
}
4878-
4879-
$expressionTypes[$variableExprString] = $variableTypeHolder;
4880-
continue;
4881-
}
4882-
4883-
$expressionTypes[$variableExprString] = new ExpressionTypeHolder(
4884-
$variableTypeHolder->getExpr(),
4885-
$variableTypeHolder->getType(),
4886-
$variableTypeHolder->getCertainty()->and($expressionTypes[$variableExprString]->getCertainty()),
4887-
);
4888-
}
4889-
4890-
$nativeTypes = $this->nativeExpressionTypes;
4891-
$initScopeNativeExpressionTypes = $initScope->nativeExpressionTypes;
4892-
foreach ($finalScope->nativeExpressionTypes as $variableExprString => $variableTypeHolder) {
4893-
if (!isset($nativeTypes[$variableExprString])) {
4894-
if (isset($initScopeNativeExpressionTypes[$variableExprString])) {
4895-
$nativeTypes[$variableExprString] = ExpressionTypeHolder::createMaybe($variableTypeHolder->getExpr(), $variableTypeHolder->getType());
4896-
continue;
4897-
}
4898-
4899-
$nativeTypes[$variableExprString] = $variableTypeHolder;
4900-
continue;
4901-
}
4902-
4903-
$nativeTypes[$variableExprString] = new ExpressionTypeHolder(
4904-
$variableTypeHolder->getExpr(),
4905-
$variableTypeHolder->getType(),
4906-
$variableTypeHolder->getCertainty()->and($nativeTypes[$variableExprString]->getCertainty()),
4907-
);
4908-
}
4909-
4910-
return $this->scopeFactory->create(
4911-
$this->context,
4912-
$this->isDeclareStrictTypes(),
4913-
$this->getFunction(),
4914-
$this->getNamespace(),
4915-
$expressionTypes,
4916-
$nativeTypes,
4917-
$this->conditionalExpressions,
4918-
$this->inClosureBindScopeClasses,
4919-
$this->anonymousFunctionReflection,
4920-
$this->inFirstLevelStatement,
4921-
[],
4922-
[],
4923-
[],
4924-
$this->afterExtractCall,
4925-
$this->parentScope,
4926-
$this->nativeTypesPromoted,
4927-
);
4928-
}
4929-
49304868
public function generalizeWith(self $otherScope): self
49314869
{
49324870
$variableTypeHolders = $this->generalizeVariableTypeHolders(

src/Analyser/NodeScopeResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1402,7 +1402,7 @@ private function processStmtNode(
14021402
}
14031403
} else {
14041404
if (!$this->polluteScopeWithLoopInitialAssignments) {
1405-
$finalScope = $scope->processAlwaysIterableForScopeWithoutPollute($finalScope, $initScope);
1405+
$finalScope = $finalScope->mergeWith($scope);
14061406
}
14071407
}
14081408

tests/PHPStan/Analyser/ForLoopNoScopePollutionTest.php

Lines changed: 0 additions & 36 deletions
This file was deleted.

tests/PHPStan/Analyser/data/for-loop-no-scope-pollution.php

Lines changed: 0 additions & 107 deletions
This file was deleted.

tests/PHPStan/Analyser/forLoopNoScopePollution.neon

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/PHPStan/Analyser/nsrt/for-loop.php

Lines changed: 0 additions & 107 deletions
This file was deleted.

tests/PHPStan/Rules/Variables/DefinedVariableRuleTest.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,13 +1068,4 @@ public function testBug10228(): void
10681068
$this->analyse([__DIR__ . '/data/bug-10228.php'], []);
10691069
}
10701070

1071-
public function testBug9550(): void
1072-
{
1073-
$this->cliArgumentsVariablesRegistered = true;
1074-
$this->polluteScopeWithLoopInitialAssignments = false;
1075-
$this->checkMaybeUndefinedVariables = true;
1076-
$this->polluteScopeWithAlwaysIterableForeach = true;
1077-
$this->analyse([__DIR__ . '/data/bug-9550.php'], []);
1078-
}
1079-
10801071
}

tests/PHPStan/Rules/Variables/data/bug-9550.php

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)