Skip to content

Commit

Permalink
Merge branch refs/heads/1.12.x into 2.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
phpstan-bot authored Nov 10, 2024
2 parents 59ef891 + f2dfd5d commit d2d137e
Show file tree
Hide file tree
Showing 8 changed files with 1 addition and 356 deletions.
62 changes: 0 additions & 62 deletions src/Analyser/MutatingScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -4865,68 +4865,6 @@ public function processAlwaysIterableForeachScopeWithoutPollute(self $finalScope
);
}

public function processAlwaysIterableForScopeWithoutPollute(self $finalScope, self $initScope): self
{
$expressionTypes = $this->expressionTypes;
$initScopeExpressionTypes = $initScope->expressionTypes;
foreach ($finalScope->expressionTypes as $variableExprString => $variableTypeHolder) {
if (!isset($expressionTypes[$variableExprString])) {
if (isset($initScopeExpressionTypes[$variableExprString])) {
$expressionTypes[$variableExprString] = ExpressionTypeHolder::createMaybe($variableTypeHolder->getExpr(), $variableTypeHolder->getType());
continue;
}

$expressionTypes[$variableExprString] = $variableTypeHolder;
continue;
}

$expressionTypes[$variableExprString] = new ExpressionTypeHolder(
$variableTypeHolder->getExpr(),
$variableTypeHolder->getType(),
$variableTypeHolder->getCertainty()->and($expressionTypes[$variableExprString]->getCertainty()),
);
}

$nativeTypes = $this->nativeExpressionTypes;
$initScopeNativeExpressionTypes = $initScope->nativeExpressionTypes;
foreach ($finalScope->nativeExpressionTypes as $variableExprString => $variableTypeHolder) {
if (!isset($nativeTypes[$variableExprString])) {
if (isset($initScopeNativeExpressionTypes[$variableExprString])) {
$nativeTypes[$variableExprString] = ExpressionTypeHolder::createMaybe($variableTypeHolder->getExpr(), $variableTypeHolder->getType());
continue;
}

$nativeTypes[$variableExprString] = $variableTypeHolder;
continue;
}

$nativeTypes[$variableExprString] = new ExpressionTypeHolder(
$variableTypeHolder->getExpr(),
$variableTypeHolder->getType(),
$variableTypeHolder->getCertainty()->and($nativeTypes[$variableExprString]->getCertainty()),
);
}

return $this->scopeFactory->create(
$this->context,
$this->isDeclareStrictTypes(),
$this->getFunction(),
$this->getNamespace(),
$expressionTypes,
$nativeTypes,
$this->conditionalExpressions,
$this->inClosureBindScopeClasses,
$this->anonymousFunctionReflection,
$this->inFirstLevelStatement,
[],
[],
[],
$this->afterExtractCall,
$this->parentScope,
$this->nativeTypesPromoted,
);
}

public function generalizeWith(self $otherScope): self
{
$variableTypeHolders = $this->generalizeVariableTypeHolders(
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/NodeScopeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -1402,7 +1402,7 @@ private function processStmtNode(
}
} else {
if (!$this->polluteScopeWithLoopInitialAssignments) {
$finalScope = $scope->processAlwaysIterableForScopeWithoutPollute($finalScope, $initScope);
$finalScope = $finalScope->mergeWith($scope);
}
}

Expand Down
36 changes: 0 additions & 36 deletions tests/PHPStan/Analyser/ForLoopNoScopePollutionTest.php

This file was deleted.

107 changes: 0 additions & 107 deletions tests/PHPStan/Analyser/data/for-loop-no-scope-pollution.php

This file was deleted.

2 changes: 0 additions & 2 deletions tests/PHPStan/Analyser/forLoopNoScopePollution.neon

This file was deleted.

107 changes: 0 additions & 107 deletions tests/PHPStan/Analyser/nsrt/for-loop.php

This file was deleted.

9 changes: 0 additions & 9 deletions tests/PHPStan/Rules/Variables/DefinedVariableRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1068,13 +1068,4 @@ public function testBug10228(): void
$this->analyse([__DIR__ . '/data/bug-10228.php'], []);
}

public function testBug9550(): void
{
$this->cliArgumentsVariablesRegistered = true;
$this->polluteScopeWithLoopInitialAssignments = false;
$this->checkMaybeUndefinedVariables = true;
$this->polluteScopeWithAlwaysIterableForeach = true;
$this->analyse([__DIR__ . '/data/bug-9550.php'], []);
}

}
32 changes: 0 additions & 32 deletions tests/PHPStan/Rules/Variables/data/bug-9550.php

This file was deleted.

0 comments on commit d2d137e

Please sign in to comment.