Skip to content

Commit

Permalink
add commands optinally
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Jun 8, 2023
1 parent 3c7cba3 commit 827b364
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 29 deletions.
13 changes: 10 additions & 3 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,17 @@
$services->set(DynamicSourceLocatorProvider::class)
->factory([service(PHPStanServicesFactory::class), 'createDynamicSourceLocatorProvider']);

$services->set(MissingInSetCommand::class);
$services->set(OutsideAnySetCommand::class);
// add commands optinally
if (class_exists(MissingInSetCommand::class)) {
$services->set(Application::class)
->call('add', [service(MissingInSetCommand::class)])
->call('add', [service(OutsideAnySetCommand::class)]);

$services->set(MissingInSetCommand::class);
$services->set(OutsideAnySetCommand::class);
}

// phpdoc parser
// phpdoc parser
$services->set(SmartPhpParser::class)
->factory([service(SmartPhpParserFactory::class), 'create']);

Expand Down
26 changes: 0 additions & 26 deletions src/Console/ConsoleApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@
use Rector\Core\Console\Command\ProcessCommand;
use Rector\Core\Console\Command\SetupCICommand;
use Rector\Core\Console\Command\WorkerCommand;
use Rector\RectorGenerator\Command\GenerateCommand;
use Rector\RectorGenerator\Command\InitRecipeCommand;
use Rector\Utils\Command\MissingInSetCommand;
use Rector\Utils\Command\OutsideAnySetCommand;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
Expand All @@ -35,32 +30,11 @@ public function __construct(
WorkerCommand $workerCommand,
SetupCICommand $setupCICommand,
ListRulesCommand $listRulesCommand,
// dev
MissingInSetCommand $missingInSetCommand = null,
OutsideAnySetCommand $outsideAnySetCommand = null,
GenerateCommand $generateCommand = null,
InitRecipeCommand $initRecipeCommand = null,
) {
parent::__construct(self::NAME, VersionResolver::PACKAGE_VERSION);

$this->addCommands([$processCommand, $workerCommand, $setupCICommand, $listRulesCommand]);

if ($missingInSetCommand instanceof Command) {
$this->add($missingInSetCommand);
}

if ($outsideAnySetCommand instanceof Command) {
$this->add($outsideAnySetCommand);
}

if ($generateCommand instanceof Command) {
$this->add($generateCommand);
}

if ($initRecipeCommand instanceof Command) {
$this->add($initRecipeCommand);
}

$this->setDefaultCommand('process');
}

Expand Down

0 comments on commit 827b364

Please sign in to comment.