Skip to content

Commit 214aa7b

Browse files
committed
fix more variants
1 parent eec834e commit 214aa7b

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

src/Analyser/NodeScopeResolver.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5392,6 +5392,7 @@ private function processAssignVar(
53925392
}
53935393
}
53945394

5395+
$scopeBeforeAssignEval = $scope;
53955396
$scope = $result->getScope();
53965397
$truthySpecifiedTypes = $this->typeSpecifier->specifyTypesInCondition($scope, $assignedExpr, TypeSpecifierContext::createTruthy());
53975398
$falseySpecifiedTypes = $this->typeSpecifier->specifyTypesInCondition($scope, $assignedExpr, TypeSpecifierContext::createFalsey());
@@ -5404,7 +5405,7 @@ private function processAssignVar(
54045405
$conditionalExpressions = $this->processSureTypesForConditionalExpressionsAfterAssign($scope, $var->name, $conditionalExpressions, $falseySpecifiedTypes, $falseyType);
54055406
$conditionalExpressions = $this->processSureNotTypesForConditionalExpressionsAfterAssign($scope, $var->name, $conditionalExpressions, $falseySpecifiedTypes, $falseyType);
54065407

5407-
$nodeCallback(new VariableAssignNode($var, $assignedExpr), $result->getScope());
5408+
$nodeCallback(new VariableAssignNode($var, $assignedExpr), $scopeBeforeAssignEval);
54085409
$scope = $scope->assignVariable($var->name, $type, $scope->getNativeType($assignedExpr), TrinaryLogic::createYes());
54095410
foreach ($conditionalExpressions as $exprString => $holders) {
54105411
$scope = $scope->addConditionalExpressions($exprString, $holders);
@@ -5575,9 +5576,9 @@ private function processAssignVar(
55755576
}
55765577
} else {
55775578
if ($var instanceof Variable) {
5578-
$nodeCallback(new VariableAssignNode($var, $assignedPropertyExpr), $scope);
5579+
$nodeCallback(new VariableAssignNode($var, $assignedPropertyExpr), $scopeBeforeAssignEval);
55795580
} elseif ($var instanceof PropertyFetch || $var instanceof StaticPropertyFetch) {
5580-
$nodeCallback(new PropertyAssignNode($var, $assignedPropertyExpr, $isAssignOp), $scope);
5581+
$nodeCallback(new PropertyAssignNode($var, $assignedPropertyExpr, $isAssignOp), $scopeBeforeAssignEval);
55815582
if ($var instanceof PropertyFetch && $var->name instanceof Node\Identifier && !$isAssignOp) {
55825583
$scope = $scope->assignInitializedProperty($scope->getType($var->var), $var->name->toString());
55835584
}

tests/PHPStan/Rules/Variables/ParameterOutAssignedTypeRuleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,9 @@ public function testBug13093(): void
6969
$this->analyse([__DIR__ . '/data/bug-13093.php'], []);
7070
}
7171

72+
public function testBug13093b(): void
73+
{
74+
$this->analyse([__DIR__ . '/data/bug-13093b.php'], []);
75+
}
76+
7277
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Bug13093b;
6+
7+
use function array_shift;
8+
9+
final class ParallelProcessRunner
10+
{
11+
/**
12+
* @var array<int, string>
13+
*/
14+
private array $nextMutantProcessKillerContainer = [];
15+
16+
public function fillBucketOnce(string &$killer): int
17+
{
18+
if ($this->nextMutantProcessKillerContainer !== []) {
19+
$killer = array_shift($this->nextMutantProcessKillerContainer);
20+
}
21+
22+
return 0;
23+
}
24+
25+
}
26+

0 commit comments

Comments
 (0)