File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99use Rector \Php55 \Rector \String_ \StringClassNameToClassConstantRector ;
1010use Rector \Php84 \Rector \Class_ \DeprecatedAnnotationToDeprecatedAttributeRector ;
1111use Rector \Symfony \Symfony44 \Rector \ClassMethod \ConsoleExecuteReturnIntRector ;
12+ use Rector \Symfony \Symfony61 \Rector \Class_ \CommandConfigureToAttributeRector ;
1213
1314return RectorConfig ::configure ()
1415 ->withPreparedSets (
4546
4647 // adds (int) cast to methods that already return int, ping-pongs with RecastingRemovalRector
4748 ConsoleExecuteReturnIntRector::class,
49+
50+ // keep console command metadata in configure(), as more readable than a single long attribute
51+ CommandConfigureToAttributeRector::class,
4852 // tests
4953 '*/Fixture* ' ,
5054 '*/Source* ' ,
Original file line number Diff line number Diff line change 1313use Rector \VersionBonding \Contract \ComposerPackageConstraintInterface ;
1414use Rector \VersionBonding \ValueObject \ComposerBoundRuleConfiguration ;
1515use ReflectionObject ;
16- use Symfony \Component \Console \Attribute \AsCommand ;
1716use Symfony \Component \Console \Command \Command ;
1817use Symfony \Component \Console \Helper \TableCell ;
1918use Symfony \Component \Console \Helper \TableSeparator ;
2423/**
2524 * @see \Rector\Tests\Console\Command\ComposerBasedCommandTest
2625 */
27- #[AsCommand(name: 'composer-based ' , description: 'Show loaded rules that are triggered by an installed composer package version ' )]
2826final class ComposerBasedCommand extends Command
2927{
3028 /**
@@ -38,6 +36,12 @@ public function __construct(
3836 parent ::__construct ();
3937 }
4038
39+ protected function configure (): void
40+ {
41+ $ this ->setName ('composer-based ' );
42+ $ this ->setDescription ('Show loaded rules that are triggered by an installed composer package version ' );
43+ }
44+
4145 protected function execute (InputInterface $ input , OutputInterface $ output ): int
4246 {
4347 $ tableRows = $ this ->createTableRows ();
Original file line number Diff line number Diff line change 1010use Rector \Enum \ClassName ;
1111use Rector \Exception \ShouldNotHappenException ;
1212use Rector \FileSystem \JsonFileSystem ;
13- use Symfony \Component \Console \Attribute \AsCommand ;
1413use Symfony \Component \Console \Command \Command ;
1514use Symfony \Component \Console \Input \InputInterface ;
1615use Symfony \Component \Console \Output \OutputInterface ;
1716use Symfony \Component \Console \Style \SymfonyStyle ;
1817use Symfony \Component \Finder \Finder ;
1918use Symfony \Component \Finder \SplFileInfo ;
2019
21- #[AsCommand(name: 'custom-rule ' , description: 'Create base of local custom rule with tests ' )]
2220final class CustomRuleCommand extends Command
2321{
2422 public function __construct (
@@ -28,6 +26,12 @@ public function __construct(
2826 parent ::__construct ();
2927 }
3028
29+ protected function configure (): void
30+ {
31+ $ this ->setName ('custom-rule ' );
32+ $ this ->setDescription ('Create base of local custom rule with tests ' );
33+ }
34+
3135 protected function execute (InputInterface $ input , OutputInterface $ output ): int
3236 {
3337 // ask for rule name
Original file line number Diff line number Diff line change 1010use Rector \Contract \Rector \RectorInterface ;
1111use Rector \PostRector \Contract \Rector \PostRectorInterface ;
1212use Rector \Skipper \SkipCriteriaResolver \SkippedClassResolver ;
13- use Symfony \Component \Console \Attribute \AsCommand ;
1413use Symfony \Component \Console \Command \Command ;
1514use Symfony \Component \Console \Input \InputInterface ;
1615use Symfony \Component \Console \Input \InputOption ;
1716use Symfony \Component \Console \Output \OutputInterface ;
1817use Symfony \Component \Console \Style \SymfonyStyle ;
1918
20- #[AsCommand(name: 'list-rules ' , description: 'Show loaded Rectors ' , aliases: ['show-rules ' ])]
2119final class ListRulesCommand extends Command
2220{
2321 /**
@@ -33,6 +31,11 @@ public function __construct(
3331
3432 protected function configure (): void
3533 {
34+ $ this ->setName ('list-rules ' );
35+ $ this ->setDescription ('Show loaded Rectors ' );
36+
37+ $ this ->setAliases (['show-rules ' ]);
38+
3639 $ this ->addOption (
3740 Option::OUTPUT_FORMAT ,
3841 null ,
Original file line number Diff line number Diff line change 2626use Rector \ValueObject \Configuration \LevelOverflow ;
2727use Rector \ValueObject \ProcessResult ;
2828use Symfony \Component \Console \Application ;
29- use Symfony \Component \Console \Attribute \AsCommand ;
3029use Symfony \Component \Console \Command \Command ;
3130use Symfony \Component \Console \Input \InputInterface ;
3231use Symfony \Component \Console \Output \OutputInterface ;
3332use Symfony \Component \Console \Style \SymfonyStyle ;
3433
35- #[AsCommand(name: 'process ' , description: 'Upgrades or refactors source code with provided Rector rules ' , aliases: ['p ' ])]
3634final class ProcessCommand extends Command
3735{
3836 public function __construct (
@@ -55,6 +53,9 @@ public function __construct(
5553
5654 protected function configure (): void
5755 {
56+ $ this ->setName ('process ' );
57+ $ this ->setAliases (['p ' ]);
58+ $ this ->setDescription ('Upgrades or refactors source code with provided Rector rules ' );
5859 $ this ->setHelp (
5960 <<<'EOF'
6061The <info>%command.name%</info> command will run Rector main feature:
Original file line number Diff line number Diff line change 77use Nette \Utils \FileSystem ;
88use OndraM \CiDetector \CiDetector ;
99use Rector \Git \RepositoryHelper ;
10- use Symfony \Component \Console \Attribute \AsCommand ;
1110use Symfony \Component \Console \Command \Command ;
1211use Symfony \Component \Console \Input \InputInterface ;
1312use Symfony \Component \Console \Output \OutputInterface ;
1413use Symfony \Component \Console \Style \SymfonyStyle ;
1514use function sprintf ;
1615
17- #[AsCommand(name: 'setup-ci ' , description: 'Add CI workflow to let Rector work for you ' )]
1816final class SetupCICommand extends Command
1917{
2018 public function __construct (
@@ -23,6 +21,12 @@ public function __construct(
2321 parent ::__construct ();
2422 }
2523
24+ protected function configure (): void
25+ {
26+ $ this ->setName ('setup-ci ' );
27+ $ this ->setDescription ('Add CI workflow to let Rector work for you ' );
28+ }
29+
2630 protected function execute (InputInterface $ input , OutputInterface $ output ): int
2731 {
2832 // detect current CI
Original file line number Diff line number Diff line change 2020use Rector \Util \MemoryLimiter ;
2121use Rector \ValueObject \Configuration ;
2222use Rector \ValueObject \Error \SystemError ;
23- use Symfony \Component \Console \Attribute \AsCommand ;
2423use Symfony \Component \Console \Command \Command ;
2524use Symfony \Component \Console \Input \InputInterface ;
2625use Symfony \Component \Console \Output \OutputInterface ;
3736 * ↓↓↓
3837 * https://github.com/phpstan/phpstan-src/commit/b84acd2e3eadf66189a64fdbc6dd18ff76323f67#diff-7f625777f1ce5384046df08abffd6c911cfbb1cfc8fcb2bdeaf78f337689e3e2
3938 */
40- #[AsCommand(name: 'worker ' , description: '[INTERNAL] Support for parallel process ' )]
4139final class WorkerCommand extends Command
4240{
4341 private const string RESULT = 'result ' ;
@@ -55,6 +53,9 @@ public function __construct(
5553
5654 protected function configure (): void
5755 {
56+ $ this ->setName ('worker ' );
57+ $ this ->setDescription ('[INTERNAL] Support for parallel process ' );
58+
5859 ProcessConfigureDecorator ::decorate ($ this );
5960
6061 parent ::configure ();
You can’t perform that action at this time.
0 commit comments