CommandNotFoundException.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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\Exception;
  11. /**
  12. * Represents an incorrect command name typed in the console.
  13. *
  14. * @author Jérôme Tamarelle <jerome@tamarelle.net>
  15. */
  16. class CommandNotFoundException extends \InvalidArgumentException implements ExceptionInterface
  17. {
  18. /**
  19. * @param string $message Exception message to throw
  20. * @param string[] $alternatives List of similar defined names
  21. * @param int $code Exception code
  22. * @param \Throwable|null $previous Previous exception used for the exception chaining
  23. */
  24. public function __construct(
  25. string $message,
  26. private array $alternatives = [],
  27. int $code = 0,
  28. ?\Throwable $previous = null,
  29. ) {
  30. parent::__construct($message, $code, $previous);
  31. }
  32. /**
  33. * @return string[]
  34. */
  35. public function getAlternatives(): array
  36. {
  37. return $this->alternatives;
  38. }
  39. }