symfonyStyle = $symfonyStyle;
$this->skippedClassResolver = $skippedClassResolver;
$this->rectors = $rectors;
parent::__construct();
}
protected function configure() : void
{
$this->setName('list-rules');
$this->setDescription('Show loaded Rectors');
$this->setAliases(['show-rules']);
$this->addOption(Option::OUTPUT_FORMAT, null, InputOption::VALUE_REQUIRED, 'Select output format', ConsoleOutputFormatter::NAME);
}
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, \true) . \PHP_EOL;
return Command::SUCCESS;
}
$this->symfonyStyle->title('Loaded Rector rules');
$this->symfonyStyle->listing($rectorClasses);
if ($skippedClasses !== []) {
$this->symfonyStyle->title('Skipped Rector rules');
$this->symfonyStyle->listing($skippedClasses);
}
$this->symfonyStyle->newLine();
$this->symfonyStyle->note(\sprintf('Loaded %d rules', \count($rectorClasses)));
return Command::SUCCESS;
}
/**
* @return array