Skip to content

Commit bc7c567

Browse files
phpstan-botclaude
andcommitted
Refactor: extract isSimpleVariableReference() method on IntertwinedVariableByReferenceWithExpr
Move the variable-type checking logic from MutatingScope::invalidateExpression() into a dedicated method for better readability. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b786213 commit bc7c567

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/Analyser/MutatingScope.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2810,10 +2810,7 @@ public function invalidateExpression(Expr $expressionToInvalidate, bool $require
28102810
$exprExpr = $exprTypeHolder->getExpr();
28112811
if (
28122812
$exprExpr instanceof IntertwinedVariableByReferenceWithExpr
2813-
&& $exprExpr->getExpr() instanceof Variable
2814-
&& is_string($exprExpr->getExpr()->name)
2815-
&& $exprExpr->getAssignedExpr() instanceof Variable
2816-
&& is_string($exprExpr->getAssignedExpr()->name)
2813+
&& $exprExpr->isSimpleVariableReference()
28172814
) {
28182815
continue;
28192816
}

src/Node/Expr/IntertwinedVariableByReferenceWithExpr.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ public function getAssignedExpr(): Expr
2929
return $this->assignedExpr;
3030
}
3131

32+
public function isSimpleVariableReference(): bool
33+
{
34+
return $this->expr instanceof \PhpParser\Node\Expr\Variable
35+
&& is_string($this->expr->name)
36+
&& $this->assignedExpr instanceof \PhpParser\Node\Expr\Variable
37+
&& is_string($this->assignedExpr->name);
38+
}
39+
3240
#[Override]
3341
public function getType(): string
3442
{

0 commit comments

Comments
 (0)