Skip to content

Commit

Permalink
Remove removeNode() from RemoveUnusedPromotedPropertyRector (#4089)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Jun 5, 2023
1 parent d54d8b1 commit 2915ab7
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ public function refactorWithScope(Node $node, Scope $scope): ?Node
return null;
}

$hasRemovedProperty = false;
$hasChanged = false;

foreach ($constructClassMethod->getParams() as $param) {
foreach ($constructClassMethod->params as $key => $param) {
// only private local scope; removing public property might be dangerous
if (! $this->visibilityManipulator->hasVisibility($param, Visibility::PRIVATE)) {
continue;
Expand All @@ -121,11 +121,11 @@ public function refactorWithScope(Node $node, Scope $scope): ?Node
}

// remove param
$this->removeNode($param);
$hasRemovedProperty = true;
unset($constructClassMethod->params[$key]);
$hasChanged = true;
}

if ($hasRemovedProperty) {
if ($hasChanged) {
return $node;
}

Expand Down

0 comments on commit 2915ab7

Please sign in to comment.