diff --git a/src/Contract/Rector/RectorInterface.php b/src/Contract/Rector/RectorInterface.php index 2602bd2a67e..89553c6c804 100644 --- a/src/Contract/Rector/RectorInterface.php +++ b/src/Contract/Rector/RectorInterface.php @@ -8,7 +8,7 @@ use PhpParser\NodeVisitor; use Symplify\RuleDocGenerator\Contract\DocumentedRuleInterface; -interface RectorInterface extends NodeVisitor, DocumentedRuleInterface +interface RectorInterface extends DocumentedRuleInterface { /** * List of nodes this class checks, classes that implements \PhpParser\Node @@ -18,6 +18,11 @@ interface RectorInterface extends NodeVisitor, DocumentedRuleInterface */ public function getNodeTypes(): array; + /** + * @return int|Node|Node[]|null + */ + public function enterNode(Node $node): int|Node|array|null; + /** * Process Node of matched type * @return Node|Node[]|null|NodeVisitor::REMOVE_NODE diff --git a/src/Rector/AbstractRector.php b/src/Rector/AbstractRector.php index db40c8f2140..ae927e9b818 100644 --- a/src/Rector/AbstractRector.php +++ b/src/Rector/AbstractRector.php @@ -4,7 +4,6 @@ namespace Rector\Rector; -use Deprecated; use PhpParser\Node; use PhpParser\Node\Expr; use PhpParser\Node\Name; @@ -17,7 +16,6 @@ use PhpParser\NodeTraverser; use PhpParser\NodeVisitor; use PhpParser\NodeVisitor\CloningVisitor; -use PhpParser\NodeVisitorAbstract; use PHPStan\Analyser\MutatingScope; use PHPStan\Type\ObjectType; use PHPStan\Type\Type; @@ -40,7 +38,7 @@ use Rector\Skipper\ValueObject\SkipMatch; use Rector\ValueObject\Application\File; -abstract class AbstractRector extends NodeVisitorAbstract implements RectorInterface +abstract class AbstractRector implements RectorInterface { private const string EMPTY_NODE_ARRAY_MESSAGE = <<refactor()" returns non-empty array for Nodes. @@ -103,26 +101,6 @@ public function autowire( $this->commentsMerger = $commentsMerger; } - /** - * @return Node[]|null - * - * @internal - */ - final public function beforeTraverse(array $nodes): ?array - { - return null; - } - - /** - * @return Node[]|null - * - * @internal - */ - final public function afterTraverse(array $nodes) - { - return null; - } - /** * @return NodeVisitor::REMOVE_NODE|Node|null|Node[] */ @@ -190,12 +168,6 @@ final public function enterNode(Node $node): int|Node|null|array return $this->postRefactorProcess($originalNode, $node, $refactoredNodeOrState, $filePath); } - #[Deprecated(message: 'no longer used')] - final public function leaveNode(Node $node): array|int|Node|null - { - return null; - } - protected function getFile(): File { $file = $this->currentFileProvider->getFile();