Skip to content

Commit 1eb46f1

Browse files
Use #[AsCommand] to describe commands
1 parent bd13bd9 commit 1eb46f1

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

Command/DebugCommand.php

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

1212
namespace Symfony\Bridge\Twig\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\Formatter\OutputFormatter;
@@ -30,11 +31,9 @@
3031
*
3132
* @author Jordi Boggiano <[email protected]>
3233
*/
34+
#[AsCommand(name: 'debug:twig', description: 'Show a list of twig functions, filters, globals and tests')]
3335
class DebugCommand extends Command
3436
{
35-
protected static $defaultName = 'debug:twig';
36-
protected static $defaultDescription = 'Show a list of twig functions, filters, globals and tests';
37-
3837
private Environment $twig;
3938
private ?string $projectDir;
4039
private array $bundlesMetadata;
@@ -66,7 +65,6 @@ protected function configure()
6665
new InputOption('filter', null, InputOption::VALUE_REQUIRED, 'Show details for all entries matching this filter'),
6766
new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (text or json)', 'text'),
6867
])
69-
->setDescription(self::$defaultDescription)
7068
->setHelp(<<<'EOF'
7169
The <info>%command.name%</info> command outputs a list of twig functions,
7270
filters, globals and tests.

Command/LintCommand.php

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

1212
namespace Symfony\Bridge\Twig\Command;
1313

14+
use Symfony\Component\Console\Attribute\AsCommand;
1415
use Symfony\Component\Console\CI\GithubActionReporter;
1516
use Symfony\Component\Console\Command\Command;
1617
use Symfony\Component\Console\Exception\InvalidArgumentException;
@@ -33,11 +34,9 @@
3334
* @author Marc Weistroff <[email protected]>
3435
* @author Jérôme Tamarelle <[email protected]>
3536
*/
37+
#[AsCommand(name: 'lint:twig', description: 'Lint a Twig template and outputs encountered errors')]
3638
class LintCommand extends Command
3739
{
38-
protected static $defaultName = 'lint:twig';
39-
protected static $defaultDescription = 'Lint a Twig template and outputs encountered errors';
40-
4140
private Environment $twig;
4241
private string $format;
4342

@@ -51,7 +50,6 @@ public function __construct(Environment $twig)
5150
protected function configure()
5251
{
5352
$this
54-
->setDescription(self::$defaultDescription)
5553
->addOption('format', null, InputOption::VALUE_REQUIRED, 'The output format')
5654
->addOption('show-deprecations', null, InputOption::VALUE_NONE, 'Show deprecations as errors')
5755
->addArgument('filename', InputArgument::IS_ARRAY, 'A file, a directory or "-" for reading from STDIN')

0 commit comments

Comments
 (0)