Skip to content

Commit 159eca6

Browse files
committed
Fix multi processing of expr in Pre/Post Inc/Dec
1 parent f7ccea9 commit 159eca6

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

src/Analyser/NodeScopeResolver.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3900,27 +3900,25 @@ static function (): void {
39003900
|| $expr instanceof Expr\PreDec
39013901
|| $expr instanceof Expr\PostDec
39023902
) {
3903-
$result = $this->processExprNode($stmt, $expr->var, $scope, $nodeCallback, $context->enterDeep());
3904-
$scope = $result->getScope();
3905-
$hasYield = $result->hasYield();
3906-
$throwPoints = $result->getThrowPoints();
3907-
$impurePoints = $result->getImpurePoints();
3908-
$isAlwaysTerminating = $result->isAlwaysTerminating();
3909-
39103903
$newExpr = $expr;
39113904
if ($expr instanceof Expr\PostInc) {
39123905
$newExpr = new Expr\PreInc($expr->var);
39133906
} elseif ($expr instanceof Expr\PostDec) {
39143907
$newExpr = new Expr\PreDec($expr->var);
39153908
}
39163909

3917-
$scope = $this->processVirtualAssign(
3910+
$result = $this->processVirtualAssign(
39183911
$scope,
39193912
$stmt,
39203913
$expr->var,
39213914
$newExpr,
39223915
$nodeCallback,
3923-
)->getScope();
3916+
);
3917+
$scope = $result->getScope();
3918+
$hasYield = $result->hasYield();
3919+
$throwPoints = $result->getThrowPoints();
3920+
$impurePoints = $result->getImpurePoints();
3921+
$isAlwaysTerminating = $result->isAlwaysTerminating();
39243922
} elseif ($expr instanceof Ternary) {
39253923
$ternaryCondResult = $this->processExprNode($stmt, $expr->cond, $scope, $nodeCallback, $context->enterDeep());
39263924
$throwPoints = $ternaryCondResult->getThrowPoints();

tests/PHPStan/Rules/Pure/PureMethodRuleTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,6 @@ public function testPureConstructor(): void
157157
{
158158
$this->treatPhpDocTypesAsCertain = true;
159159
$this->analyse([__DIR__ . '/data/pure-constructor.php'], [
160-
[
161-
'Impure static property access in pure method PureConstructor\Foo::__construct().',
162-
19,
163-
],
164160
[
165161
'Impure property assignment in pure method PureConstructor\Foo::__construct().',
166162
19,

0 commit comments

Comments
 (0)