summaryrefslogtreecommitdiff
path: root/vendor/symfony/console/Attribute
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/symfony/console/Attribute')
-rw-r--r--vendor/symfony/console/Attribute/AsCommand.php45
1 files changed, 45 insertions, 0 deletions
diff --git a/vendor/symfony/console/Attribute/AsCommand.php b/vendor/symfony/console/Attribute/AsCommand.php
new file mode 100644
index 0000000..6066d7c
--- /dev/null
+++ b/vendor/symfony/console/Attribute/AsCommand.php
@@ -0,0 +1,45 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Console\Attribute;
13
14/**
15 * Service tag to autoconfigure commands.
16 */
17#[\Attribute(\Attribute::TARGET_CLASS)]
18class AsCommand
19{
20 /**
21 * @param string $name The name of the command, used when calling it (i.e. "cache:clear")
22 * @param string|null $description The description of the command, displayed with the help page
23 * @param string[] $aliases The list of aliases of the command. The command will be executed when using one of them (i.e. "cache:clean")
24 * @param bool $hidden If true, the command won't be shown when listing all the available commands, but it can still be run as any other command
25 */
26 public function __construct(
27 public string $name,
28 public ?string $description = null,
29 array $aliases = [],
30 bool $hidden = false,
31 ) {
32 if (!$hidden && !$aliases) {
33 return;
34 }
35
36 $name = explode('|', $name);
37 $name = array_merge($name, $aliases);
38
39 if ($hidden && '' !== $name[0]) {
40 array_unshift($name, '');
41 }
42
43 $this->name = implode('|', $name);
44 }
45}