Skip to content

Commit

Permalink
[Core] Refactor RectifiedAnalyzer: early check against AbstractScopeA…
Browse files Browse the repository at this point in the history
…wareRector instead of Original node (#2295)
  • Loading branch information
samsonasik committed May 12, 2022
1 parent 2ccb535 commit cd2a644
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/ProcessAnalyzer/RectifiedAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,17 @@ private function shouldContinue(RectifiedNode $rectifiedNode, RectorInterface $r
return false;
}

if ($rector instanceof AbstractScopeAwareRector) {
$scope = $node->getAttribute(AttributeKey::SCOPE);
return $scope instanceof Scope;
}

$originalNode = $node->getAttribute(AttributeKey::ORIGINAL_NODE);
if ($originalNode instanceof Node) {
return true;
}

$startTokenPos = $node->getStartTokenPos();
if ($startTokenPos >= 0) {
return false;
}

if (! $rector instanceof AbstractScopeAwareRector) {
return true;
}

$scope = $node->getAttribute(AttributeKey::SCOPE);
return $scope instanceof Scope;
return $startTokenPos < 0;
}
}

0 comments on commit cd2a644

Please sign in to comment.