Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Jun 11, 2022
1 parent ccdd189 commit ee28b38
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions rules/Removing/NodeManipulator/ComplexNodeRemover.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function removePropertyAndUsages(
$removeAssignSideEffect,
$propertyName,
&$totalPropertyFetch
) {
):?Node {
// here should be checked all expr like stmts that can hold assign, e.f. if, foreach etc. etc.
if (! $node instanceof Expression) {
return null;
Expand Down Expand Up @@ -81,17 +81,22 @@ public function removePropertyAndUsages(
return null;
}

$currentTotalPropertyFetch = $totalPropertyFetch;
foreach ($propertyFetches as $propertyFetch) {
if ($this->nodeNameResolver->isName($propertyFetch->name, $propertyName)) {
if (! $removeAssignSideEffect && $this->sideEffectNodeDetector->detect($assign->expr)) {
return null;
}

$this->nodeRemover->removeNode($node);
--$totalPropertyFetch;
}
}

if ($totalPropertyFetch < $currentTotalPropertyFetch) {
$this->nodeRemover->removeNode($node);
return $node;
}

return null;
});

Expand Down

0 comments on commit ee28b38

Please sign in to comment.