diff --git a/src/Console/Command/ListRulesCommand.php b/src/Console/Command/ListRulesCommand.php index bcb5480b93d..2e3b58d3cdd 100644 --- a/src/Console/Command/ListRulesCommand.php +++ b/src/Console/Command/ListRulesCommand.php @@ -11,6 +11,7 @@ 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; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -23,6 +24,7 @@ final class ListRulesCommand extends Command */ public function __construct( private readonly RectorOutputStyle $rectorOutputStyle, + private readonly SkippedClassResolver $skippedClassResolver, private readonly array $rectors ) { parent::__construct(); @@ -46,10 +48,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int { $rectorClasses = $this->resolveRectorClasses(); + $skippedClasses = $this->getSkippedCheckers(); + $outputFormat = $input->getOption(Option::OUTPUT_FORMAT); if ($outputFormat === 'json') { $data = [ 'rectors' => $rectorClasses, + 'skipped-rectors' => $skippedClasses, ]; echo Json::encode($data, Json::PRETTY) . PHP_EOL; @@ -59,6 +64,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->rectorOutputStyle->title('Loaded Rector rules'); $this->rectorOutputStyle->listing($rectorClasses); + if ($skippedClasses !== []) { + $this->rectorOutputStyle->title('Skipped Rector rules'); + $this->rectorOutputStyle->listing($skippedClasses); + } + return Command::SUCCESS; } @@ -83,4 +93,22 @@ static function (RectorInterface $rector): bool { return $rectorClasses; } + + /** + * @return string[] + */ + private function getSkippedCheckers(): array + { + $skippedCheckers = []; + foreach ($this->skippedClassResolver->resolve() as $checkerClass => $fileList) { + // ignore specific skips + if ($fileList !== null) { + continue; + } + + $skippedCheckers[] = $checkerClass; + } + + return $skippedCheckers; + } }