mirror of
https://github.com/rectorphp/rector.git
synced 2025-03-14 04:19:44 +01:00
use ContributorCommandInterface instead of explicit command checks
This commit is contained in:
parent
e3ffb69230
commit
689155cec2
@ -7,7 +7,7 @@ use Nette\Utils\Strings;
|
||||
use Rector\CodingStyle\AfterRectorCodingStyle;
|
||||
use Rector\ContributorTools\Configuration\Configuration;
|
||||
use Rector\ContributorTools\Configuration\ConfigurationFactory;
|
||||
use Rector\ContributorTools\Exception\Command\MaintainerCommandInterface;
|
||||
use Rector\ContributorTools\Exception\Command\ContributorCommandInterface;
|
||||
use Rector\ContributorTools\TemplateVariablesFactory;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
@ -22,7 +22,7 @@ use function Safe\getcwd;
|
||||
use function Safe\sort;
|
||||
use function Safe\sprintf;
|
||||
|
||||
final class CreateRectorCommand extends Command implements MaintainerCommandInterface
|
||||
final class CreateRectorCommand extends Command implements ContributorCommandInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
|
@ -8,7 +8,7 @@ use Rector\Console\Command\AbstractCommand;
|
||||
use Rector\Console\Shell;
|
||||
use Rector\ConsoleDiffer\MarkdownDifferAndFormatter;
|
||||
use Rector\Contract\Rector\RectorInterface;
|
||||
use Rector\ContributorTools\Exception\Command\MaintainerCommandInterface;
|
||||
use Rector\ContributorTools\Exception\Command\ContributorCommandInterface;
|
||||
use Rector\Error\ExceptionCorrector;
|
||||
use Rector\Exception\ShouldNotHappenException;
|
||||
use Rector\RectorDefinition\ConfiguredCodeSample;
|
||||
@ -21,7 +21,7 @@ use Symplify\PackageBuilder\Console\Command\CommandNaming;
|
||||
use function Safe\ksort;
|
||||
use function Safe\sprintf;
|
||||
|
||||
final class GenerateDocsCommand extends AbstractCommand implements MaintainerCommandInterface
|
||||
final class GenerateDocsCommand extends AbstractCommand implements ContributorCommandInterface
|
||||
{
|
||||
/**
|
||||
* @var SymfonyStyle
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
namespace Rector\ContributorTools\Exception\Command;
|
||||
|
||||
interface MaintainerCommandInterface
|
||||
interface ContributorCommandInterface
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -3,8 +3,7 @@
|
||||
namespace Rector\Console;
|
||||
|
||||
use Jean85\PrettyVersions;
|
||||
use Rector\Console\Command\GenerateRectorOverviewCommand;
|
||||
use Rector\ContributorTools\Command\CreateRectorCommand;
|
||||
use Rector\ContributorTools\Exception\Command\ContributorCommandInterface;
|
||||
use Symfony\Component\Console\Application as SymfonyApplication;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputDefinition;
|
||||
@ -12,7 +11,6 @@ use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symplify\PackageBuilder\Console\Command\CommandNaming;
|
||||
use function Safe\getcwd;
|
||||
use function Safe\realpath;
|
||||
|
||||
@ -47,7 +45,7 @@ final class Application extends SymfonyApplication
|
||||
$shouldFollowByNewline = false;
|
||||
|
||||
// skip in this case, since generate content must be clear from meta-info
|
||||
if ($input->getFirstArgument() === CommandNaming::classToName(GenerateRectorOverviewCommand::class)) {
|
||||
if (is_a($input->getFirstArgument(), ContributorCommandInterface::class, true)) {
|
||||
return parent::doRun($input, $output);
|
||||
}
|
||||
|
||||
@ -92,11 +90,7 @@ final class Application extends SymfonyApplication
|
||||
}
|
||||
|
||||
$filteredCommands = array_filter($commands, function (Command $command): bool {
|
||||
return ! in_array(
|
||||
get_class($command),
|
||||
[CreateRectorCommand::class, GenerateRectorOverviewCommand::class],
|
||||
true
|
||||
);
|
||||
return ! $command instanceof ContributorCommandInterface;
|
||||
});
|
||||
|
||||
return array_values($filteredCommands);
|
||||
|
Loading…
x
Reference in New Issue
Block a user