Skip to content
Merged
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
9 changes: 5 additions & 4 deletions src/PostRector/Application/PostFileProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public function __construct(
private readonly ClassRenamingPostRector $classRenamingPostRector,
private readonly DocblockNameImportingPostRector $docblockNameImportingPostRector,
private readonly UnusedImportRemovingPostRector $unusedImportRemovingPostRector,
private readonly RenamedClassesDataCollector $renamedClassesDataCollector
private readonly RenamedClassesDataCollector $renamedClassesDataCollector,
private readonly RenameClassRector $renameClassRector
) {
}

Expand Down Expand Up @@ -70,13 +71,13 @@ public function traverse(array $stmts, File $file): array
*/
private function shouldSkipPostRector(PostRectorInterface $postRector, string $filePath, array $stmts): bool
{
if ($this->skipper->shouldSkipElementAndFilePath($postRector, $filePath)) {
if ($this->skipper->shouldSkipRectorAndFile($postRector, $filePath)) {
return true;
}

// skip renaming if rename class rector is skipped
if ($postRector instanceof ClassRenamingPostRector && $this->skipper->shouldSkipElementAndFilePath(
RenameClassRector::class,
if ($postRector instanceof ClassRenamingPostRector && $this->skipper->shouldSkipRectorAndFile(
$this->renameClassRector,
$filePath
)) {
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/Skipper/Skipper/Skipper.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ public function shouldSkipFilePath(string $filePath): bool
return $this->pathSkipper->shouldSkip($filePath);
}

public function shouldSkipElementAndFilePath(string|object $element, string $filePath): bool
public function shouldSkipRectorAndFile(object $rector, string $filePath): bool
{
$skipMatch = $this->matchSkip($element, $filePath);
$skipMatch = $this->matchSkip($rector, $filePath);
if (! $skipMatch instanceof SkipMatch) {
return false;
}
Expand Down
14 changes: 7 additions & 7 deletions tests/Skipper/Skipper/SkipperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ public static function provideDataShouldSkipFilePath(): Iterator
}

#[DataProvider('provideCheckerAndFile')]
public function testSkipElementAndFilePath(string $element, string $filePath, bool $expectedSkip): void
public function testSkipRectorAndFile(object $rector, string $filePath, bool $expectedSkip): void
{
$resolvedSkip = $this->skipper->shouldSkipElementAndFilePath($element, $filePath);
$resolvedSkip = $this->skipper->shouldSkipRectorAndFile($rector, $filePath);
$this->assertSame($expectedSkip, $resolvedSkip);
}

Expand All @@ -80,12 +80,12 @@ public function testSkipElementAndFilePath(string $element, string $filePath, bo
*/
public static function provideCheckerAndFile(): Iterator
{
yield [FifthElement::class, __DIR__ . '/Fixture', true];
yield [new FifthElement(), __DIR__ . '/Fixture', true];

yield [AnotherClassToSkip::class, __DIR__ . '/Fixture/someFile', true];
yield [AnotherClassToSkip::class, __DIR__ . '/Fixture/someDirectory/anotherFile.php', true];
yield [new AnotherClassToSkip(), __DIR__ . '/Fixture/someFile', true];
yield [new AnotherClassToSkip(), __DIR__ . '/Fixture/someDirectory/anotherFile.php', true];

yield [NotSkippedClass::class, __DIR__ . '/Fixture/someFile', false];
yield [NotSkippedClass::class, __DIR__ . '/Fixture/someOtherFile', false];
yield [new NotSkippedClass(), __DIR__ . '/Fixture/someFile', false];
yield [new NotSkippedClass(), __DIR__ . '/Fixture/someOtherFile', false];
}
}
6 changes: 3 additions & 3 deletions tests/Skipper/Skipper/UsedSkipCollectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected function tearDown(): void
public function testCollectsOnlyMatchedSkips(): void
{
$this->skipper->shouldSkipFilePath('tests/Skipper/Skipper/Fixture/SomeSkippedPath/any.txt');
$this->skipper->shouldSkipElementAndFilePath(FifthElement::class, __FILE__);
$this->skipper->shouldSkipRectorAndFile(new FifthElement(), __FILE__);

$usedSkips = $this->usedSkipCollector->provide();

Expand All @@ -76,8 +76,8 @@ public function testCollectsMatchedPathNotRuleClassForRuleScopedSkip(): void
],
]);

$this->skipper->shouldSkipElementAndFilePath(
AnotherClassToSkip::class,
$this->skipper->shouldSkipRectorAndFile(
new AnotherClassToSkip(),
__DIR__ . '/Fixture/someDirectory/anotherFile.php'
);

Expand Down
Loading