Skip to content

Commit

Permalink
[DeadCode] Remove next attribute on RemoveUnusedVariableAssignRector (#…
Browse files Browse the repository at this point in the history
…3917)

* [DeadCode] Remove next attribute on RemoveUnusedVariableAssignRector

* [ci-review] Rector Rectify

---------

Co-authored-by: GitHub Action <actions@github.com>
  • Loading branch information
samsonasik and actions-user committed May 21, 2023
1 parent 8ec3a27 commit 33c04c5
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,10 @@ private function refactorUsedVariable(Assign $assign, Scope $scope): null|Expr
return null;
}

$if = $parentNode->getAttribute(AttributeKey::NEXT_NODE);
$node = $this->betterNodeFinder->resolveNextNode($parentNode);

// check if next node is if
if (! $if instanceof If_) {
if (! $node instanceof If_) {
if (
$assign->var instanceof Variable &&
! $scope->hasVariableType((string) $this->getName($assign->var))
Expand All @@ -249,7 +249,7 @@ private function refactorUsedVariable(Assign $assign, Scope $scope): null|Expr
return null;
}

if ($this->conditionSearcher->hasIfAndElseForVariableRedeclaration($assign, $if)) {
if ($this->conditionSearcher->hasIfAndElseForVariableRedeclaration($assign, $node)) {
$this->removeNode($assign);
return $assign;
}
Expand Down

0 comments on commit 33c04c5

Please sign in to comment.