mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-15 13:25:30 +01:00
drop AbstactCommand, inline (#5761)
This commit is contained in:
parent
124a13dde8
commit
bfa5416077
@ -609,3 +609,7 @@ parameters:
|
||||
- '#Content of method "matchReturnMethodCall\(\)" is duplicated with method "matchReturnMethodCall\(\)" in "Rector\\Defluent\\Rector\\Return_\\ReturnFluentChainMethodCallToNormalMethodCallRector" class\. Use unique content or service instead#'
|
||||
- '#Content of method "matchReturnMethodCall\(\)" is duplicated with method "matchReturnMethodCall\(\)" in "Rector\\Defluent\\Rector\\Return_\\ReturnNewFluentChainMethodCallToNonFluentRector" class\. Use unique content or service instead#'
|
||||
- '#Content of method "decoratePropertyWithDocBlock\(\)" is duplicated with method "decoratePropertyWithDocBlock\(\)" in "Rector\\DowngradePhp74\\Rector\\Property\\DowngradeTypedPropertyRector" class\. Use unique content or service instead#'
|
||||
-
|
||||
message: '#Argument and options "debug" got confused#'
|
||||
paths:
|
||||
- src/Console/Command/ProcessCommand.php
|
||||
|
@ -1,52 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Core\Console\Command;
|
||||
|
||||
use Rector\Caching\Detector\ChangedFilesDetector;
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
abstract class AbstractCommand extends Command
|
||||
{
|
||||
/**
|
||||
* @var ChangedFilesDetector
|
||||
*/
|
||||
protected $changedFilesDetector;
|
||||
|
||||
/**
|
||||
* @required
|
||||
*/
|
||||
public function autowireAbstractCommand(ChangedFilesDetector $changedFilesDetector): void
|
||||
{
|
||||
$this->changedFilesDetector = $changedFilesDetector;
|
||||
}
|
||||
|
||||
protected function initialize(InputInterface $input, OutputInterface $output): void
|
||||
{
|
||||
$application = $this->getApplication();
|
||||
if (! $application instanceof Application) {
|
||||
throw new ShouldNotHappenException();
|
||||
}
|
||||
|
||||
$optionDebug = (bool) $input->getOption(Option::OPTION_DEBUG);
|
||||
if ($optionDebug) {
|
||||
$application->setCatchExceptions(false);
|
||||
|
||||
// clear cache
|
||||
$this->changedFilesDetector->clear();
|
||||
return;
|
||||
}
|
||||
|
||||
// clear cache
|
||||
$optionClearCache = (bool) $input->getOption(Option::OPTION_CLEAR_CACHE);
|
||||
if ($optionClearCache) {
|
||||
$this->changedFilesDetector->clear();
|
||||
}
|
||||
}
|
||||
}
|
@ -5,11 +5,12 @@ declare(strict_types=1);
|
||||
namespace Rector\Core\Console\Command;
|
||||
|
||||
use Rector\RectorGenerator\TemplateInitializer;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symplify\PackageBuilder\Console\ShellCode;
|
||||
|
||||
final class InitCommand extends AbstractCommand
|
||||
final class InitCommand extends Command
|
||||
{
|
||||
/**
|
||||
* @var TemplateInitializer
|
||||
|
@ -13,12 +13,15 @@ use Rector\Core\Autoloading\AdditionalAutoloader;
|
||||
use Rector\Core\Configuration\Configuration;
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\Console\Output\OutputFormatterCollector;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\FileSystem\FilesFinder;
|
||||
use Rector\Core\FileSystem\PhpFilesFinder;
|
||||
use Rector\Core\Guard\RectorGuard;
|
||||
use Rector\Core\NonPhpFile\NonPhpFileProcessor;
|
||||
use Rector\Core\PhpParser\NodeTraverser\RectorNodeTraverser;
|
||||
use Rector\Core\ValueObject\StaticNonPhpFileSuffixes;
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
@ -26,7 +29,7 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symplify\PackageBuilder\Console\ShellCode;
|
||||
|
||||
final class ProcessCommand extends AbstractCommand
|
||||
final class ProcessCommand extends Command
|
||||
{
|
||||
/**
|
||||
* @var FilesFinder
|
||||
@ -88,6 +91,11 @@ final class ProcessCommand extends AbstractCommand
|
||||
*/
|
||||
private $phpFilesFinder;
|
||||
|
||||
/**
|
||||
* @var ChangedFilesDetector
|
||||
*/
|
||||
private $changedFilesDetector;
|
||||
|
||||
public function __construct(
|
||||
AdditionalAutoloader $additionalAutoloader,
|
||||
ChangedFilesDetector $changedFilesDetector,
|
||||
@ -123,11 +131,13 @@ final class ProcessCommand extends AbstractCommand
|
||||
protected function configure(): void
|
||||
{
|
||||
$this->setDescription('Upgrade or refactor source code with provided rectors');
|
||||
|
||||
$this->addArgument(
|
||||
Option::SOURCE,
|
||||
InputArgument::OPTIONAL | InputArgument::IS_ARRAY,
|
||||
'Files or directories to be upgraded.'
|
||||
);
|
||||
|
||||
$this->addOption(
|
||||
Option::OPTION_DRY_RUN,
|
||||
'n',
|
||||
@ -237,6 +247,29 @@ final class ProcessCommand extends AbstractCommand
|
||||
return ShellCode::ERROR;
|
||||
}
|
||||
|
||||
protected function initialize(InputInterface $input, OutputInterface $output): void
|
||||
{
|
||||
$application = $this->getApplication();
|
||||
if (! $application instanceof Application) {
|
||||
throw new ShouldNotHappenException();
|
||||
}
|
||||
|
||||
$optionDebug = (bool) $input->getOption(Option::OPTION_DEBUG);
|
||||
if ($optionDebug) {
|
||||
$application->setCatchExceptions(false);
|
||||
|
||||
// clear cache
|
||||
$this->changedFilesDetector->clear();
|
||||
return;
|
||||
}
|
||||
|
||||
// clear cache
|
||||
$optionClearCache = (bool) $input->getOption(Option::OPTION_CLEAR_CACHE);
|
||||
if ($optionClearCache) {
|
||||
$this->changedFilesDetector->clear();
|
||||
}
|
||||
}
|
||||
|
||||
private function reportZeroCacheRectorsCondition(): void
|
||||
{
|
||||
if (! $this->configuration->isCacheEnabled()) {
|
||||
|
@ -6,6 +6,7 @@ namespace Rector\Core\Console\Command;
|
||||
|
||||
use Rector\Core\Application\ActiveRectorsProvider;
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
@ -13,7 +14,7 @@ use Symplify\PackageBuilder\Console\ShellCode;
|
||||
use Symplify\PackageBuilder\Parameter\ParameterProvider;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class ShowCommand extends AbstractCommand
|
||||
final class ShowCommand extends Command
|
||||
{
|
||||
/**
|
||||
* @var SymfonyStyle
|
||||
|
Loading…
x
Reference in New Issue
Block a user