mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-24 03:35:01 +01:00
ProcessCommand: sort Rector by class name, show only diff for files, no need to list count and their names
This commit is contained in:
parent
afe8f03ba3
commit
94c675c9a4
@ -74,13 +74,13 @@ final class ProcessCommand extends Command
|
||||
ParameterProvider $parameterProvider,
|
||||
DifferAndFormatter $differAndFormatter
|
||||
) {
|
||||
parent::__construct();
|
||||
|
||||
$this->fileProcessor = $fileProcessor;
|
||||
$this->rectorCollector = $rectorCollector;
|
||||
$this->symfonyStyle = $symfonyStyle;
|
||||
$this->phpFilesFinder = $phpFilesFinder;
|
||||
$this->processCommandReporter = $processCommandReporter;
|
||||
|
||||
parent::__construct();
|
||||
$this->parameterProvider = $parameterProvider;
|
||||
$this->differAndFormatter = $differAndFormatter;
|
||||
}
|
||||
@ -94,7 +94,12 @@ final class ProcessCommand extends Command
|
||||
InputArgument::REQUIRED | InputArgument::IS_ARRAY,
|
||||
'Files or directories to be upgraded.'
|
||||
);
|
||||
$this->addOption(self::OPTION_DRY_RUN, null, InputOption::VALUE_NONE, 'See diff of changes, do not save them to files.');
|
||||
$this->addOption(
|
||||
self::OPTION_DRY_RUN,
|
||||
null,
|
||||
InputOption::VALUE_NONE,
|
||||
'See diff of changes, do not save them to files.'
|
||||
);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
@ -109,9 +114,6 @@ final class ProcessCommand extends Command
|
||||
$this->processCommandReporter->reportLoadedRectors();
|
||||
|
||||
$this->processFiles($files);
|
||||
|
||||
$this->processCommandReporter->reportChangedFiles();
|
||||
|
||||
$this->symfonyStyle->success('Rector is done!');
|
||||
|
||||
return 0;
|
||||
@ -136,8 +138,9 @@ final class ProcessCommand extends Command
|
||||
{
|
||||
$this->symfonyStyle->title('Processing files');
|
||||
|
||||
$i = 1;
|
||||
foreach ($fileInfos as $fileInfo) {
|
||||
$this->symfonyStyle->writeln(sprintf(' - %s', $fileInfo->getRealPath()));
|
||||
$this->symfonyStyle->writeln(sprintf('<options=bold>%d) %s</>', $i, $fileInfo->getPathname()));
|
||||
|
||||
if ($this->parameterProvider->provideParameter(self::OPTION_DRY_RUN)) {
|
||||
$oldContent = $fileInfo->getContents();
|
||||
@ -149,6 +152,8 @@ final class ProcessCommand extends Command
|
||||
} else {
|
||||
$this->fileProcessor->processFile($fileInfo);
|
||||
}
|
||||
|
||||
++$i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,12 @@ final class ProcessCommandReporter
|
||||
$this->rectorCollector->getRectorCount() === 1 ? '' : 's'
|
||||
));
|
||||
|
||||
foreach ($this->rectorCollector->getRectors() as $rector) {
|
||||
$rectorList = $this->rectorCollector->getRectors();
|
||||
usort($rectorList, function ($first, $second) {
|
||||
return get_class($first) <=> get_class($second);
|
||||
});
|
||||
|
||||
foreach ($rectorList as $rector) {
|
||||
$this->symfonyStyle->writeln(sprintf(
|
||||
' - %s',
|
||||
get_class($rector)
|
||||
@ -50,20 +55,4 @@ final class ProcessCommandReporter
|
||||
|
||||
$this->symfonyStyle->newLine();
|
||||
}
|
||||
|
||||
public function reportChangedFiles(): void
|
||||
{
|
||||
$this->symfonyStyle->title(sprintf(
|
||||
'%d Changed File%s',
|
||||
$this->changedFilesCollector->getChangedFilesCount(),
|
||||
$this->changedFilesCollector->getChangedFilesCount() === 1 ? '' : 's'
|
||||
));
|
||||
|
||||
foreach ($this->changedFilesCollector->getChangedFiles() as $fileInfo) {
|
||||
$this->symfonyStyle->writeln(sprintf(
|
||||
' - %s',
|
||||
$fileInfo
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user