diff --git a/rules-tests/Renaming/Rector/Name/RenameClassRector/config/skip_after_defined_configured_rule.php b/rules-tests/Renaming/Rector/Name/RenameClassRector/config/skip_after_defined_configured_rule.php index 4ab81ef9905..9f54e63d47f 100644 --- a/rules-tests/Renaming/Rector/Name/RenameClassRector/config/skip_after_defined_configured_rule.php +++ b/rules-tests/Renaming/Rector/Name/RenameClassRector/config/skip_after_defined_configured_rule.php @@ -10,10 +10,9 @@ return static function (RectorConfig $rectorConfig): void { $rectorConfig->removeUnusedImports(); - $rectorConfig - ->ruleWithConfiguration(RenameClassRector::class, [ - OldClass::class => NewClass::class, - ]); + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, [ + OldClass::class => NewClass::class, + ]); // skip the path after defined $rectorConfig->skip([ diff --git a/src/Application/FileProcessor.php b/src/Application/FileProcessor.php index 1fc05375392..48e6a470341 100644 --- a/src/Application/FileProcessor.php +++ b/src/Application/FileProcessor.php @@ -44,6 +44,7 @@ public function __construct( private RectorParser $rectorParser, private NodeScopeAndMetadataDecorator $nodeScopeAndMetadataDecorator, private UsedImportsResolver $usedImportsResolver, + private RectorRegistry $rectorRegistry, ) { } @@ -59,6 +60,9 @@ public function processFile(File $file, Configuration $configuration): FileProce $fileHasChanged = false; $filePath = $file->getFilePath(); + $currentRectors = $this->rectorRegistry->forFile($file); + $this->rectorNodeTraverser->refreshPhpRectors($currentRectors); + do { $file->changeHasChanged(false); diff --git a/src/Application/RectorRegistry.php b/src/Application/RectorRegistry.php index 31dba5a7fc3..33051dee352 100644 --- a/src/Application/RectorRegistry.php +++ b/src/Application/RectorRegistry.php @@ -6,7 +6,6 @@ use Rector\Contract\Rector\HTMLAverseRectorInterface; use Rector\Contract\Rector\RectorInterface; -use Rector\Skipper\Skipper\Skipper; use Rector\ValueObject\Application\File; /** @@ -19,7 +18,6 @@ final class RectorRegistry */ public function __construct( private array $rectors, - private readonly Skipper $skipper ) { } @@ -41,10 +39,6 @@ public function forFile(File $file): array { $rectorsForPath = []; foreach ($this->rectors as $rector) { - if ($this->skipper->shouldSkipRectorAndFile($rector, $file->getFilePath())) { - continue; - } - if ($rector instanceof HTMLAverseRectorInterface && $file->containsHTML()) { continue; } diff --git a/src/PhpParser/NodeTraverser/RectorNodeTraverser.php b/src/PhpParser/NodeTraverser/RectorNodeTraverser.php index a076c16c92c..b26aa8a54b7 100644 --- a/src/PhpParser/NodeTraverser/RectorNodeTraverser.php +++ b/src/PhpParser/NodeTraverser/RectorNodeTraverser.php @@ -62,7 +62,6 @@ public function traverse(array $nodes): array /** * @param RectorInterface[] $rectors - * @api used in tests to update the active rules * * @internal Used only in Rector core, not supported outside. Might change any time. */ diff --git a/src/PostRector/Application/PostFileProcessor.php b/src/PostRector/Application/PostFileProcessor.php index 7d1c8a0e338..2fe43fb7b89 100644 --- a/src/PostRector/Application/PostFileProcessor.php +++ b/src/PostRector/Application/PostFileProcessor.php @@ -71,10 +71,6 @@ public function traverse(array $stmts, File $file): array */ private function shouldSkipPostRector(PostRectorInterface $postRector, string $filePath, array $stmts): bool { - if ($this->skipper->shouldSkipRectorAndFile($postRector, $filePath)) { - return true; - } - // skip renaming if rename class rector is skipped if ($postRector instanceof ClassRenamingPostRector && $this->skipper->shouldSkipRectorAndFile( $this->renameClassRector, diff --git a/src/Rector/RectorRunner.php b/src/Rector/RectorRunner.php index b8b90593ede..e0690dc744d 100644 --- a/src/Rector/RectorRunner.php +++ b/src/Rector/RectorRunner.php @@ -13,7 +13,6 @@ use Rector\Application\ChangedNodeScopeRefresher; use Rector\Application\Provider\CurrentFileProvider; use Rector\ChangesReporting\ValueObject\RectorWithLineChange; -use Rector\Contract\Rector\HTMLAverseRectorInterface; use Rector\Contract\Rector\RectorInterface; use Rector\Exception\ShouldNotHappenException; use Rector\NodeDecorator\CreatedByRuleDecorator; @@ -56,11 +55,6 @@ public function __construct( public function run(RectorInterface $rector, Node $node): int|Node|null|array { $file = $this->getFile(); - - if ($rector instanceof HTMLAverseRectorInterface && $file->containsHTML()) { - return null; - } - $filePath = $file->getFilePath(); // node already changed by this rule in a previous pass → hard skip diff --git a/src/Reporting/UnusedSkipResolver.php b/src/Reporting/UnusedSkipResolver.php index 81fe5515b25..dac0212045b 100644 --- a/src/Reporting/UnusedSkipResolver.php +++ b/src/Reporting/UnusedSkipResolver.php @@ -7,8 +7,8 @@ use Rector\Configuration\Option; use Rector\Configuration\Parameter\SimpleParameterProvider; use Rector\FileSystem\FilePathHelper; -use Rector\Skipper\Skipper\Skipper; use Rector\Skipper\SkipCriteriaResolver\SkippedPathsResolver; +use Rector\Skipper\Skipper\Skipper; use Rector\ValueObject\ProcessResult; /** diff --git a/tests/Application/RectorRegistryTest.php b/tests/Application/RectorRegistryTest.php index 4c97439ecbf..ab8c4e9c281 100644 --- a/tests/Application/RectorRegistryTest.php +++ b/tests/Application/RectorRegistryTest.php @@ -34,11 +34,6 @@ protected function tearDown(): void public function testForFile(): void { - $file = new File(__DIR__ . '/skipped_directory/some_file.php', ''); - $rectorsForPath = $this->rectorRegistry->forFile($file); - - $this->assertSame([], $rectorsForPath); - $file = new File(__DIR__ . '/some_file.php', ''); $rectorsForPath = $this->rectorRegistry->forFile($file);