Skip to content
Merged

misc #8602

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
4 changes: 4 additions & 0 deletions src/Application/FileProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public function __construct(
private RectorParser $rectorParser,
private NodeScopeAndMetadataDecorator $nodeScopeAndMetadataDecorator,
private UsedImportsResolver $usedImportsResolver,
private RectorRegistry $rectorRegistry,
) {
}

Expand All @@ -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);

Expand Down
6 changes: 0 additions & 6 deletions src/Application/RectorRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use Rector\Contract\Rector\HTMLAverseRectorInterface;
use Rector\Contract\Rector\RectorInterface;
use Rector\Skipper\Skipper\Skipper;
use Rector\ValueObject\Application\File;

/**
Expand All @@ -19,7 +18,6 @@ final class RectorRegistry
*/
public function __construct(
private array $rectors,
private readonly Skipper $skipper
) {
}

Expand All @@ -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;
}
Expand Down
1 change: 0 additions & 1 deletion src/PhpParser/NodeTraverser/RectorNodeTraverser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
4 changes: 0 additions & 4 deletions src/PostRector/Application/PostFileProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 0 additions & 6 deletions src/Rector/RectorRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Reporting/UnusedSkipResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
5 changes: 0 additions & 5 deletions tests/Application/RectorRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Loading