diff --git a/config/services-packages.php b/config/services-packages.php index 2fb637c7bf1..9463833b659 100644 --- a/config/services-packages.php +++ b/config/services-packages.php @@ -20,7 +20,6 @@ __DIR__ . '/../packages/BetterPhpDocParser/PhpDoc', __DIR__ . '/../packages/PHPStanStaticTypeMapper/Enum', __DIR__ . '/../packages/Caching/Cache.php', - __DIR__ . '/../packages/NodeTypeResolver/NodeVisitor/FileNodeVisitor.php', // used in PHPStan __DIR__ . '/../packages/NodeTypeResolver/Reflection/BetterReflection/RectorBetterReflectionSourceLocatorFactory.php', diff --git a/packages/NodeTypeResolver/NodeScopeAndMetadataDecorator.php b/packages/NodeTypeResolver/NodeScopeAndMetadataDecorator.php index 6f8972918d5..26498195232 100644 --- a/packages/NodeTypeResolver/NodeScopeAndMetadataDecorator.php +++ b/packages/NodeTypeResolver/NodeScopeAndMetadataDecorator.php @@ -10,7 +10,6 @@ use PhpParser\NodeVisitor\NameResolver; use PhpParser\NodeVisitor\NodeConnectingVisitor; use Rector\Core\ValueObject\Application\File; -use Rector\NodeTypeResolver\NodeVisitor\FileNodeVisitor; use Rector\NodeTypeResolver\NodeVisitor\FunctionLikeParamArgPositionNodeVisitor; use Rector\NodeTypeResolver\NodeVisitor\FunctionMethodAndClassNodeVisitor; use Rector\NodeTypeResolver\NodeVisitor\NamespaceNodeVisitor; @@ -79,9 +78,6 @@ public function decorateNodesFromFile(File $file, array $stmts): array $nodeTraverserForFormatPreservePrinting->addVisitor($this->namespaceNodeVisitor); $nodeTraverserForFormatPreservePrinting->addVisitor($this->functionLikeParamArgPositionNodeVisitor); - $fileNodeVisitor = new FileNodeVisitor($file); - $nodeTraverserForFormatPreservePrinting->addVisitor($fileNodeVisitor); - $stmts = $nodeTraverserForFormatPreservePrinting->traverse($stmts); // this split is needed, so nodes have names, classes and namespaces diff --git a/packages/NodeTypeResolver/NodeVisitor/FileNodeVisitor.php b/packages/NodeTypeResolver/NodeVisitor/FileNodeVisitor.php deleted file mode 100644 index a6b2d95063e..00000000000 --- a/packages/NodeTypeResolver/NodeVisitor/FileNodeVisitor.php +++ /dev/null @@ -1,30 +0,0 @@ -setAttribute(AttributeKey::FILE, $this->file); - return $node; - } -} diff --git a/rules/Php74/Rector/LNumber/AddLiteralSeparatorToNumberRector.php b/rules/Php74/Rector/LNumber/AddLiteralSeparatorToNumberRector.php index e2433337bcc..62030b9da2f 100644 --- a/rules/Php74/Rector/LNumber/AddLiteralSeparatorToNumberRector.php +++ b/rules/Php74/Rector/LNumber/AddLiteralSeparatorToNumberRector.php @@ -10,7 +10,6 @@ use PhpParser\Node\Scalar\LNumber; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; -use Rector\Core\ValueObject\Application\File; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\VersionBonding\Contract\MinPhpVersionInterface; @@ -142,14 +141,7 @@ private function shouldSkip(LNumber | DNumber $node, string $numericValueAsStrin /** @var int $startToken */ $startToken = $node->getAttribute(AttributeKey::START_TOKEN_POSITION); - $file = $node->getAttribute(AttributeKey::FILE); - - // new node - if (! $file instanceof File) { - return true; - } - - $oldTokens = $file->getOldTokens(); + $oldTokens = $this->file->getOldTokens(); foreach ($oldTokens[$startToken] as $token) { if (! is_string($token)) { diff --git a/rules/PhpSpecToPHPUnit/Rector/Class_/RenameSpecFileToTestFileRector.php b/rules/PhpSpecToPHPUnit/Rector/Class_/RenameSpecFileToTestFileRector.php index 5a0563f30b4..5e3f25f8799 100644 --- a/rules/PhpSpecToPHPUnit/Rector/Class_/RenameSpecFileToTestFileRector.php +++ b/rules/PhpSpecToPHPUnit/Rector/Class_/RenameSpecFileToTestFileRector.php @@ -71,9 +71,7 @@ public function refactor(Node $node): ?Node } $newPathName = $this->createPathName($oldPathname); - - $file = $node->getAttribute(AttributeKey::FILE); - $this->removedAndAddedFilesCollector->addMovedFile($file, $newPathName); + $this->removedAndAddedFilesCollector->addMovedFile($this->file, $newPathName); return null; } diff --git a/rules/Restoration/Rector/ClassLike/UpdateFileNameByClassNameFileSystemRector.php b/rules/Restoration/Rector/ClassLike/UpdateFileNameByClassNameFileSystemRector.php index 0160530f177..efb9abff294 100644 --- a/rules/Restoration/Rector/ClassLike/UpdateFileNameByClassNameFileSystemRector.php +++ b/rules/Restoration/Rector/ClassLike/UpdateFileNameByClassNameFileSystemRector.php @@ -8,7 +8,6 @@ use PhpParser\Node\Stmt\ClassLike; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\Application\File; -use Rector\NodeTypeResolver\Node\AttributeKey; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; @@ -65,14 +64,9 @@ public function refactor(Node $node): ?Node return null; } - $file = $node->getAttribute(AttributeKey::FILE); - if (! $file instanceof File) { - return null; - } - // no match → rename file $newFileLocation = $smartFileInfo->getPath() . DIRECTORY_SEPARATOR . $classShortName . '.php'; - $this->removedAndAddedFilesCollector->addMovedFile($file, $newFileLocation); + $this->removedAndAddedFilesCollector->addMovedFile($this->file, $newFileLocation); return null; }