diff --git a/src/NodeTypeResolver/Node/AttributeKey.php b/src/NodeTypeResolver/Node/AttributeKey.php index c65de9ebb2b..0539d4b4dce 100644 --- a/src/NodeTypeResolver/Node/AttributeKey.php +++ b/src/NodeTypeResolver/Node/AttributeKey.php @@ -63,11 +63,6 @@ final class AttributeKey public const string IS_REGULAR_PATTERN = 'is_regular_pattern'; - /** - * Helps with infinite loop detection - */ - public const string CREATED_BY_RULE = 'created_by_rule'; - public const string WRAPPED_IN_PARENTHESES = 'wrapped_in_parentheses'; /** diff --git a/src/ProcessAnalyzer/RectifiedAnalyzer.php b/src/ProcessAnalyzer/RectifiedAnalyzer.php deleted file mode 100644 index 8130b64f251..00000000000 --- a/src/ProcessAnalyzer/RectifiedAnalyzer.php +++ /dev/null @@ -1,77 +0,0 @@ -= 0 - */ -final readonly class RectifiedAnalyzer -{ - public function __construct( - private ScopeAnalyzer $scopeAnalyzer - ) { - } - - /** - * @param class-string $rectorClass - */ - public function hasRectified(string $rectorClass, Node $node): bool - { - $originalNode = $node->getAttribute(AttributeKey::ORIGINAL_NODE); - if ($this->hasConsecutiveCreatedByRule($rectorClass, $node, $originalNode)) { - return true; - } - - return $this->isJustReprintedOverlappedTokenStart($node, $originalNode); - } - - /** - * @param class-string $rectorClass - */ - private function hasConsecutiveCreatedByRule(string $rectorClass, Node $node, ?Node $originalNode): bool - { - $createdByRuleNode = $originalNode ?? $node; - /** @var class-string[] $createdByRule */ - $createdByRule = $createdByRuleNode->getAttribute(AttributeKey::CREATED_BY_RULE) ?? []; - - if ($createdByRule === []) { - return false; - } - - return end($createdByRule) === $rectorClass; - } - - private function isJustReprintedOverlappedTokenStart(Node $node, ?Node $originalNode): bool - { - if ($originalNode instanceof Node) { - return false; - } - - /** - * Start token pos must be < 0 to continue, as the node and parent node just re-printed - * - * - Node's original node is null - * - Parent Node's original node is null - */ - $startTokenPos = $node->getStartTokenPos(); - if ($startTokenPos >= 0) { - return true; - } - - if (! $this->scopeAnalyzer->isRefreshable($node)) { - return false; - } - - return ! in_array(AttributeKey::SCOPE, array_keys($node->getAttributes()), true); - } -} diff --git a/src/Skipper/Skipper/Skipper.php b/src/Skipper/Skipper/Skipper.php index 446c84c4589..62b621a18ff 100644 --- a/src/Skipper/Skipper/Skipper.php +++ b/src/Skipper/Skipper/Skipper.php @@ -4,13 +4,10 @@ namespace Rector\Skipper\Skipper; -use PhpParser\Node; use PHPStan\Reflection\ReflectionProvider; use Rector\Configuration\Deprecation\Contract\DeprecatedInterface; use Rector\Configuration\Option; use Rector\Configuration\Parameter\SimpleParameterProvider; -use Rector\Contract\Rector\RectorInterface; -use Rector\ProcessAnalyzer\RectifiedAnalyzer; use Rector\Skipper\Matcher\FileInfoMatcher; use Rector\Skipper\ValueObject\SkipMatch; use Rector\Testing\PHPUnit\StaticPHPUnitEnvironment; @@ -36,7 +33,6 @@ final class Skipper private array $usedSkips = []; public function __construct( - private readonly RectifiedAnalyzer $rectifiedAnalyzer, private readonly PathSkipper $pathSkipper, private readonly FileInfoMatcher $fileInfoMatcher, private readonly ReflectionProvider $reflectionProvider, @@ -170,14 +166,6 @@ public function resolveDeprecatedSkippedClasses(): array ); } - /** - * @param class-string $rectorClass - */ - public function shouldSkipCurrentNode(string $rectorClass, Node $node): bool - { - return $this->rectifiedAnalyzer->hasRectified($rectorClass, $node); - } - private function markUsed(string $skip, ?string $path = null): void { $this->usedSkips[$skip] ??= [];