Skip to content

Commit 54788c6

Browse files
Use #[AsCommand] to describe commands
1 parent 7361c59 commit 54788c6

27 files changed

+54
-104
lines changed

Command/AboutCommand.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Command;
1313

14+
use Symfony\Component\Console\Attribute\AsCommand;
1415
use Symfony\Component\Console\Command\Command;
1516
use Symfony\Component\Console\Helper\Helper;
1617
use Symfony\Component\Console\Helper\TableSeparator;
@@ -27,18 +28,15 @@
2728
*
2829
* @final
2930
*/
31+
#[AsCommand(name: 'about', description: 'Display information about the current project')]
3032
class AboutCommand extends Command
3133
{
32-
protected static $defaultName = 'about';
33-
protected static $defaultDescription = 'Display information about the current project';
34-
3534
/**
3635
* {@inheritdoc}
3736
*/
3837
protected function configure()
3938
{
4039
$this
41-
->setDescription(self::$defaultDescription)
4240
->setHelp(<<<'EOT'
4341
The <info>%command.name%</info> command displays information about the current Symfony project.
4442

Command/AssetsInstallCommand.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Command;
1313

14+
use Symfony\Component\Console\Attribute\AsCommand;
1415
use Symfony\Component\Console\Command\Command;
1516
use Symfony\Component\Console\Exception\InvalidArgumentException;
1617
use Symfony\Component\Console\Input\InputArgument;
@@ -33,15 +34,13 @@
3334
*
3435
* @final
3536
*/
37+
#[AsCommand(name: 'assets:install', description: 'Install bundle\'s web assets under a public directory')]
3638
class AssetsInstallCommand extends Command
3739
{
3840
public const METHOD_COPY = 'copy';
3941
public const METHOD_ABSOLUTE_SYMLINK = 'absolute symlink';
4042
public const METHOD_RELATIVE_SYMLINK = 'relative symlink';
4143

42-
protected static $defaultName = 'assets:install';
43-
protected static $defaultDescription = 'Install bundle\'s web assets under a public directory';
44-
4544
private $filesystem;
4645
private $projectDir;
4746

@@ -65,7 +64,6 @@ protected function configure()
6564
->addOption('symlink', null, InputOption::VALUE_NONE, 'Symlink the assets instead of copying them')
6665
->addOption('relative', null, InputOption::VALUE_NONE, 'Make relative symlinks')
6766
->addOption('no-cleanup', null, InputOption::VALUE_NONE, 'Do not remove the assets of the bundles that no longer exist')
68-
->setDescription(self::$defaultDescription)
6967
->setHelp(<<<'EOT'
7068
The <info>%command.name%</info> command installs bundle assets into a given
7169
directory (e.g. the <comment>public</comment> directory).

Command/CacheClearCommand.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Command;
1313

14+
use Symfony\Component\Console\Attribute\AsCommand;
1415
use Symfony\Component\Console\Command\Command;
1516
use Symfony\Component\Console\Exception\RuntimeException;
1617
use Symfony\Component\Console\Input\InputInterface;
@@ -33,11 +34,9 @@
3334
*
3435
* @final
3536
*/
37+
#[AsCommand(name: 'cache:clear', description: 'Clear the cache')]
3638
class CacheClearCommand extends Command
3739
{
38-
protected static $defaultName = 'cache:clear';
39-
protected static $defaultDescription = 'Clear the cache';
40-
4140
private $cacheClearer;
4241
private $filesystem;
4342

@@ -59,7 +58,6 @@ protected function configure()
5958
new InputOption('no-warmup', '', InputOption::VALUE_NONE, 'Do not warm up the cache'),
6059
new InputOption('no-optional-warmers', '', InputOption::VALUE_NONE, 'Skip optional cache warmers (faster)'),
6160
])
62-
->setDescription(self::$defaultDescription)
6361
->setHelp(<<<'EOF'
6462
The <info>%command.name%</info> command clears and warms up the application cache for a given environment
6563
and debug mode:

Command/CachePoolClearCommand.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bundle\FrameworkBundle\Command;
1313

1414
use Psr\Cache\CacheItemPoolInterface;
15+
use Symfony\Component\Console\Attribute\AsCommand;
1516
use Symfony\Component\Console\Command\Command;
1617
use Symfony\Component\Console\Exception\InvalidArgumentException;
1718
use Symfony\Component\Console\Input\InputArgument;
@@ -25,11 +26,9 @@
2526
*
2627
* @author Nicolas Grekas <[email protected]>
2728
*/
29+
#[AsCommand(name: 'cache:pool:clear', description: 'Clear cache pools')]
2830
final class CachePoolClearCommand extends Command
2931
{
30-
protected static $defaultName = 'cache:pool:clear';
31-
protected static $defaultDescription = 'Clear cache pools';
32-
3332
private $poolClearer;
3433

3534
public function __construct(Psr6CacheClearer $poolClearer)
@@ -48,7 +47,6 @@ protected function configure()
4847
->setDefinition([
4948
new InputArgument('pools', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'A list of cache pools or cache pool clearers'),
5049
])
51-
->setDescription(self::$defaultDescription)
5250
->setHelp(<<<'EOF'
5351
The <info>%command.name%</info> command clears the given cache pools or cache pool clearers.
5452

Command/CachePoolDeleteCommand.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Command;
1313

14+
use Symfony\Component\Console\Attribute\AsCommand;
1415
use Symfony\Component\Console\Command\Command;
1516
use Symfony\Component\Console\Input\InputArgument;
1617
use Symfony\Component\Console\Input\InputInterface;
@@ -23,11 +24,9 @@
2324
*
2425
* @author Pierre du Plessis <[email protected]>
2526
*/
27+
#[AsCommand(name: 'cache:pool:delete', description: 'Delete an item from a cache pool')]
2628
final class CachePoolDeleteCommand extends Command
2729
{
28-
protected static $defaultName = 'cache:pool:delete';
29-
protected static $defaultDescription = 'Delete an item from a cache pool';
30-
3130
private $poolClearer;
3231

3332
public function __construct(Psr6CacheClearer $poolClearer)
@@ -47,7 +46,6 @@ protected function configure()
4746
new InputArgument('pool', InputArgument::REQUIRED, 'The cache pool from which to delete an item'),
4847
new InputArgument('key', InputArgument::REQUIRED, 'The cache key to delete from the pool'),
4948
])
50-
->setDescription(self::$defaultDescription)
5149
->setHelp(<<<'EOF'
5250
The <info>%command.name%</info> deletes an item from a given cache pool.
5351

Command/CachePoolListCommand.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Command;
1313

14+
use Symfony\Component\Console\Attribute\AsCommand;
1415
use Symfony\Component\Console\Command\Command;
1516
use Symfony\Component\Console\Input\InputInterface;
1617
use Symfony\Component\Console\Output\OutputInterface;
@@ -21,11 +22,9 @@
2122
*
2223
* @author Tobias Nyholm <[email protected]>
2324
*/
25+
#[AsCommand(name: 'cache:pool:list', description: 'List available cache pools')]
2426
final class CachePoolListCommand extends Command
2527
{
26-
protected static $defaultName = 'cache:pool:list';
27-
protected static $defaultDescription = 'List available cache pools';
28-
2928
private $poolNames;
3029

3130
public function __construct(array $poolNames)
@@ -41,7 +40,6 @@ public function __construct(array $poolNames)
4140
protected function configure()
4241
{
4342
$this
44-
->setDescription(self::$defaultDescription)
4543
->setHelp(<<<'EOF'
4644
The <info>%command.name%</info> command lists all available cache pools.
4745
EOF

Command/CachePoolPruneCommand.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bundle\FrameworkBundle\Command;
1313

1414
use Symfony\Component\Cache\PruneableInterface;
15+
use Symfony\Component\Console\Attribute\AsCommand;
1516
use Symfony\Component\Console\Command\Command;
1617
use Symfony\Component\Console\Input\InputInterface;
1718
use Symfony\Component\Console\Output\OutputInterface;
@@ -22,11 +23,9 @@
2223
*
2324
* @author Rob Frawley 2nd <[email protected]>
2425
*/
26+
#[AsCommand(name: 'cache:pool:prune', description: 'Prune cache pools')]
2527
final class CachePoolPruneCommand extends Command
2628
{
27-
protected static $defaultName = 'cache:pool:prune';
28-
protected static $defaultDescription = 'Prune cache pools';
29-
3029
private $pools;
3130

3231
/**
@@ -45,7 +44,6 @@ public function __construct(iterable $pools)
4544
protected function configure()
4645
{
4746
$this
48-
->setDescription(self::$defaultDescription)
4947
->setHelp(<<<'EOF'
5048
The <info>%command.name%</info> command deletes all expired items from all pruneable pools.
5149

Command/CacheWarmupCommand.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Command;
1313

14+
use Symfony\Component\Console\Attribute\AsCommand;
1415
use Symfony\Component\Console\Command\Command;
1516
use Symfony\Component\Console\Input\InputInterface;
1617
use Symfony\Component\Console\Input\InputOption;
@@ -26,11 +27,9 @@
2627
*
2728
* @final
2829
*/
30+
#[AsCommand(name: 'cache:warmup', description: 'Warm up an empty cache')]
2931
class CacheWarmupCommand extends Command
3032
{
31-
protected static $defaultName = 'cache:warmup';
32-
protected static $defaultDescription = 'Warm up an empty cache';
33-
3433
private $cacheWarmer;
3534

3635
public function __construct(CacheWarmerAggregate $cacheWarmer)
@@ -49,7 +48,6 @@ protected function configure()
4948
->setDefinition([
5049
new InputOption('no-optional-warmers', '', InputOption::VALUE_NONE, 'Skip optional cache warmers (faster)'),
5150
])
52-
->setDescription(self::$defaultDescription)
5351
->setHelp(<<<'EOF'
5452
The <info>%command.name%</info> command warms up the cache.
5553

Command/ConfigDebugCommand.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Config\Definition\ConfigurationInterface;
1515
use Symfony\Component\Config\Definition\Processor;
16+
use Symfony\Component\Console\Attribute\AsCommand;
1617
use Symfony\Component\Console\Exception\LogicException;
1718
use Symfony\Component\Console\Input\InputArgument;
1819
use Symfony\Component\Console\Input\InputInterface;
@@ -31,11 +32,9 @@
3132
*
3233
* @final
3334
*/
35+
#[AsCommand(name: 'debug:config', description: 'Dump the current configuration for an extension')]
3436
class ConfigDebugCommand extends AbstractConfigCommand
3537
{
36-
protected static $defaultName = 'debug:config';
37-
protected static $defaultDescription = 'Dump the current configuration for an extension';
38-
3938
/**
4039
* {@inheritdoc}
4140
*/
@@ -46,7 +45,6 @@ protected function configure()
4645
new InputArgument('name', InputArgument::OPTIONAL, 'The bundle name or the extension alias'),
4746
new InputArgument('path', InputArgument::OPTIONAL, 'The configuration option path'),
4847
])
49-
->setDescription(self::$defaultDescription)
5048
->setHelp(<<<'EOF'
5149
The <info>%command.name%</info> command dumps the current configuration for an
5250
extension/bundle.

Command/ConfigDumpReferenceCommand.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\Config\Definition\ConfigurationInterface;
1515
use Symfony\Component\Config\Definition\Dumper\XmlReferenceDumper;
1616
use Symfony\Component\Config\Definition\Dumper\YamlReferenceDumper;
17+
use Symfony\Component\Console\Attribute\AsCommand;
1718
use Symfony\Component\Console\Exception\InvalidArgumentException;
1819
use Symfony\Component\Console\Input\InputArgument;
1920
use Symfony\Component\Console\Input\InputInterface;
@@ -33,11 +34,9 @@
3334
*
3435
* @final
3536
*/
37+
#[AsCommand(name: 'config:dump-reference', description: 'Dump the default configuration for an extension')]
3638
class ConfigDumpReferenceCommand extends AbstractConfigCommand
3739
{
38-
protected static $defaultName = 'config:dump-reference';
39-
protected static $defaultDescription = 'Dump the default configuration for an extension';
40-
4140
/**
4241
* {@inheritdoc}
4342
*/
@@ -49,7 +48,6 @@ protected function configure()
4948
new InputArgument('path', InputArgument::OPTIONAL, 'The configuration option path'),
5049
new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (yaml or xml)', 'yaml'),
5150
])
52-
->setDescription(self::$defaultDescription)
5351
->setHelp(<<<'EOF'
5452
The <info>%command.name%</info> command dumps the default configuration for an
5553
extension/bundle.

0 commit comments

Comments
 (0)