Skip to content

Commit

Permalink
[DX] Remove complementary interface, as not practical (#4757)
Browse files Browse the repository at this point in the history
Co-authored-by: GitHub Action <actions@github.com>
  • Loading branch information
TomasVotruba and actions-user committed Aug 10, 2023
1 parent e0167e6 commit fe4d90d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 36 deletions.

This file was deleted.

15 changes: 2 additions & 13 deletions src/Configuration/ConfigInitializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Rector\Core\Contract\Rector\RectorInterface;
use Rector\Core\FileSystem\InitFilePathsResolver;
use Rector\Core\Php\PhpVersionProvider;
use Rector\PostRector\Contract\Rector\ComplementaryRectorInterface;
use Rector\PostRector\Contract\Rector\PostRectorInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
Expand All @@ -30,11 +29,7 @@ public function __construct(
private readonly SymfonyStyle $symfonyStyle,
private readonly PhpVersionProvider $phpVersionProvider,
) {
if ($rectors instanceof RewindableGenerator) {
$this->rectors = iterator_to_array($rectors->getIterator());
} else {
$this->rectors = $rectors;
}
$this->rectors = $rectors instanceof RewindableGenerator ? iterator_to_array($rectors->getIterator()) : $rectors;
}

public function createConfig(string $projectDirectory): void
Expand Down Expand Up @@ -77,13 +72,7 @@ private function filterActiveRectors(array $rectors): array
{
return array_filter(
$rectors,
static function (RectorInterface $rector): bool {
if ($rector instanceof PostRectorInterface) {
return false;
}

return ! $rector instanceof ComplementaryRectorInterface;
}
static fn(RectorInterface $rector): bool => ! $rector instanceof PostRectorInterface
);
}

Expand Down
9 changes: 1 addition & 8 deletions src/Console/Command/ListRulesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Rector\ChangesReporting\Output\ConsoleOutputFormatter;
use Rector\Core\Configuration\Option;
use Rector\Core\Contract\Rector\RectorInterface;
use Rector\PostRector\Contract\Rector\ComplementaryRectorInterface;
use Rector\PostRector\Contract\Rector\PostRectorInterface;
use Rector\Skipper\SkipCriteriaResolver\SkippedClassResolver;
use Symfony\Component\Console\Command\Command;
Expand Down Expand Up @@ -91,13 +90,7 @@ private function resolveRectorClasses(): array
{
$customRectors = array_filter(
$this->rectors,
static function (RectorInterface $rector): bool {
if ($rector instanceof PostRectorInterface) {
return false;
}

return ! $rector instanceof ComplementaryRectorInterface;
}
static fn(RectorInterface $rector): bool => ! $rector instanceof PostRectorInterface
);

$rectorClasses = array_map(static fn (RectorInterface $rector): string => $rector::class, $customRectors);
Expand Down
3 changes: 1 addition & 2 deletions src/NonPhpFile/Rector/RenameClassNonPhpRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@
use Rector\Core\Configuration\RenamedClassesDataCollector;
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
use Rector\Core\Contract\Rector\NonPhpRectorInterface;
use Rector\PostRector\Contract\Rector\ComplementaryRectorInterface;
use Symplify\RuleDocGenerator\Contract\ConfigurableRuleInterface;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
use Webmozart\Assert\Assert;

final class RenameClassNonPhpRector implements NonPhpRectorInterface, ConfigurableRuleInterface, ConfigurableRectorInterface, ComplementaryRectorInterface
final class RenameClassNonPhpRector implements NonPhpRectorInterface, ConfigurableRuleInterface, ConfigurableRectorInterface
{
/**
* @see https://regex101.com/r/HKUFJD/7
Expand Down

0 comments on commit fe4d90d

Please sign in to comment.