AsCommand.php 861 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Console\Attribute;
  11. /**
  12. * Service tag to autoconfigure commands.
  13. */
  14. #[\Attribute(\Attribute::TARGET_CLASS)]
  15. class AsCommand
  16. {
  17. public function __construct(
  18. public string $name,
  19. public ?string $description = null,
  20. array $aliases = [],
  21. bool $hidden = false,
  22. ) {
  23. if (!$hidden && !$aliases) {
  24. return;
  25. }
  26. $name = explode('|', $name);
  27. $name = array_merge($name, $aliases);
  28. if ($hidden && '' !== $name[0]) {
  29. array_unshift($name, '');
  30. }
  31. $this->name = implode('|', $name);
  32. }
  33. }