Skip to content

Commit

Permalink
[Php80] Returns null on no change on ClassPropertyAssignToConstructor…
Browse files Browse the repository at this point in the history
…PromotionRector (#6418)
  • Loading branch information
samsonasik authored Nov 12, 2024
1 parent 0cac71a commit d2db35e
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ public function refactor(Node $node): ?Node
return null;
}

$hasChanged = false;
foreach ($promotionCandidates as $promotionCandidate) {
$param = $promotionCandidate->getParam();

Expand Down Expand Up @@ -186,6 +187,8 @@ public function refactor(Node $node): ?Node
continue;
}

$hasChanged = true;

// remove property from class
$propertyStmtKey = $property->getAttribute(AttributeKey::STMT_KEY);
unset($node->stmts[$propertyStmtKey]);
Expand Down Expand Up @@ -249,6 +252,10 @@ public function refactor(Node $node): ?Node
});
}

if (! $hasChanged) {
return null;
}

return $node;
}

Expand Down

0 comments on commit d2db35e

Please sign in to comment.