diff options
Diffstat (limited to 'vendor/symfony/console/Event')
| -rw-r--r-- | vendor/symfony/console/Event/ConsoleCommandEvent.php | 54 | ||||
| -rw-r--r-- | vendor/symfony/console/Event/ConsoleErrorEvent.php | 58 | ||||
| -rw-r--r-- | vendor/symfony/console/Event/ConsoleEvent.php | 56 | ||||
| -rw-r--r-- | vendor/symfony/console/Event/ConsoleSignalEvent.php | 56 | ||||
| -rw-r--r-- | vendor/symfony/console/Event/ConsoleTerminateEvent.php | 50 |
5 files changed, 274 insertions, 0 deletions
diff --git a/vendor/symfony/console/Event/ConsoleCommandEvent.php b/vendor/symfony/console/Event/ConsoleCommandEvent.php new file mode 100644 index 0000000..0757a23 --- /dev/null +++ b/vendor/symfony/console/Event/ConsoleCommandEvent.php | |||
| @@ -0,0 +1,54 @@ | |||
| 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 | |||
| 12 | namespace Symfony\Component\Console\Event; | ||
| 13 | |||
| 14 | /** | ||
| 15 | * Allows to do things before the command is executed, like skipping the command or executing code before the command is | ||
| 16 | * going to be executed. | ||
| 17 | * | ||
| 18 | * Changing the input arguments will have no effect. | ||
| 19 | * | ||
| 20 | * @author Fabien Potencier <fabien@symfony.com> | ||
| 21 | */ | ||
| 22 | final class ConsoleCommandEvent extends ConsoleEvent | ||
| 23 | { | ||
| 24 | /** | ||
| 25 | * The return code for skipped commands, this will also be passed into the terminate event. | ||
| 26 | */ | ||
| 27 | public const RETURN_CODE_DISABLED = 113; | ||
| 28 | |||
| 29 | /** | ||
| 30 | * Indicates if the command should be run or skipped. | ||
| 31 | */ | ||
| 32 | private bool $commandShouldRun = true; | ||
| 33 | |||
| 34 | /** | ||
| 35 | * Disables the command, so it won't be run. | ||
| 36 | */ | ||
| 37 | public function disableCommand(): bool | ||
| 38 | { | ||
| 39 | return $this->commandShouldRun = false; | ||
| 40 | } | ||
| 41 | |||
| 42 | public function enableCommand(): bool | ||
| 43 | { | ||
| 44 | return $this->commandShouldRun = true; | ||
| 45 | } | ||
| 46 | |||
| 47 | /** | ||
| 48 | * Returns true if the command is runnable, false otherwise. | ||
| 49 | */ | ||
| 50 | public function commandShouldRun(): bool | ||
| 51 | { | ||
| 52 | return $this->commandShouldRun; | ||
| 53 | } | ||
| 54 | } | ||
diff --git a/vendor/symfony/console/Event/ConsoleErrorEvent.php b/vendor/symfony/console/Event/ConsoleErrorEvent.php new file mode 100644 index 0000000..1c0d626 --- /dev/null +++ b/vendor/symfony/console/Event/ConsoleErrorEvent.php | |||
| @@ -0,0 +1,58 @@ | |||
| 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 | |||
| 12 | namespace Symfony\Component\Console\Event; | ||
| 13 | |||
| 14 | use Symfony\Component\Console\Command\Command; | ||
| 15 | use Symfony\Component\Console\Input\InputInterface; | ||
| 16 | use Symfony\Component\Console\Output\OutputInterface; | ||
| 17 | |||
| 18 | /** | ||
| 19 | * Allows to handle throwables thrown while running a command. | ||
| 20 | * | ||
| 21 | * @author Wouter de Jong <wouter@wouterj.nl> | ||
| 22 | */ | ||
| 23 | final class ConsoleErrorEvent extends ConsoleEvent | ||
| 24 | { | ||
| 25 | private int $exitCode; | ||
| 26 | |||
| 27 | public function __construct( | ||
| 28 | InputInterface $input, | ||
| 29 | OutputInterface $output, | ||
| 30 | private \Throwable $error, | ||
| 31 | ?Command $command = null, | ||
| 32 | ) { | ||
| 33 | parent::__construct($command, $input, $output); | ||
| 34 | } | ||
| 35 | |||
| 36 | public function getError(): \Throwable | ||
| 37 | { | ||
| 38 | return $this->error; | ||
| 39 | } | ||
| 40 | |||
| 41 | public function setError(\Throwable $error): void | ||
| 42 | { | ||
| 43 | $this->error = $error; | ||
| 44 | } | ||
| 45 | |||
| 46 | public function setExitCode(int $exitCode): void | ||
| 47 | { | ||
| 48 | $this->exitCode = $exitCode; | ||
| 49 | |||
| 50 | $r = new \ReflectionProperty($this->error, 'code'); | ||
| 51 | $r->setValue($this->error, $this->exitCode); | ||
| 52 | } | ||
| 53 | |||
| 54 | public function getExitCode(): int | ||
| 55 | { | ||
| 56 | return $this->exitCode ?? (\is_int($this->error->getCode()) && 0 !== $this->error->getCode() ? $this->error->getCode() : 1); | ||
| 57 | } | ||
| 58 | } | ||
diff --git a/vendor/symfony/console/Event/ConsoleEvent.php b/vendor/symfony/console/Event/ConsoleEvent.php new file mode 100644 index 0000000..2f9f077 --- /dev/null +++ b/vendor/symfony/console/Event/ConsoleEvent.php | |||
| @@ -0,0 +1,56 @@ | |||
| 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 | |||
| 12 | namespace Symfony\Component\Console\Event; | ||
| 13 | |||
| 14 | use Symfony\Component\Console\Command\Command; | ||
| 15 | use Symfony\Component\Console\Input\InputInterface; | ||
| 16 | use Symfony\Component\Console\Output\OutputInterface; | ||
| 17 | use Symfony\Contracts\EventDispatcher\Event; | ||
| 18 | |||
| 19 | /** | ||
| 20 | * Allows to inspect input and output of a command. | ||
| 21 | * | ||
| 22 | * @author Francesco Levorato <git@flevour.net> | ||
| 23 | */ | ||
| 24 | class ConsoleEvent extends Event | ||
| 25 | { | ||
| 26 | public function __construct( | ||
| 27 | protected ?Command $command, | ||
| 28 | private InputInterface $input, | ||
| 29 | private OutputInterface $output, | ||
| 30 | ) { | ||
| 31 | } | ||
| 32 | |||
| 33 | /** | ||
| 34 | * Gets the command that is executed. | ||
| 35 | */ | ||
| 36 | public function getCommand(): ?Command | ||
| 37 | { | ||
| 38 | return $this->command; | ||
| 39 | } | ||
| 40 | |||
| 41 | /** | ||
| 42 | * Gets the input instance. | ||
| 43 | */ | ||
| 44 | public function getInput(): InputInterface | ||
| 45 | { | ||
| 46 | return $this->input; | ||
| 47 | } | ||
| 48 | |||
| 49 | /** | ||
| 50 | * Gets the output instance. | ||
| 51 | */ | ||
| 52 | public function getOutput(): OutputInterface | ||
| 53 | { | ||
| 54 | return $this->output; | ||
| 55 | } | ||
| 56 | } | ||
diff --git a/vendor/symfony/console/Event/ConsoleSignalEvent.php b/vendor/symfony/console/Event/ConsoleSignalEvent.php new file mode 100644 index 0000000..b27f08a --- /dev/null +++ b/vendor/symfony/console/Event/ConsoleSignalEvent.php | |||
| @@ -0,0 +1,56 @@ | |||
| 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 | |||
| 12 | namespace Symfony\Component\Console\Event; | ||
| 13 | |||
| 14 | use Symfony\Component\Console\Command\Command; | ||
| 15 | use Symfony\Component\Console\Input\InputInterface; | ||
| 16 | use Symfony\Component\Console\Output\OutputInterface; | ||
| 17 | |||
| 18 | /** | ||
| 19 | * @author marie <marie@users.noreply.github.com> | ||
| 20 | */ | ||
| 21 | final class ConsoleSignalEvent extends ConsoleEvent | ||
| 22 | { | ||
| 23 | public function __construct( | ||
| 24 | Command $command, | ||
| 25 | InputInterface $input, | ||
| 26 | OutputInterface $output, | ||
| 27 | private int $handlingSignal, | ||
| 28 | private int|false $exitCode = 0, | ||
| 29 | ) { | ||
| 30 | parent::__construct($command, $input, $output); | ||
| 31 | } | ||
| 32 | |||
| 33 | public function getHandlingSignal(): int | ||
| 34 | { | ||
| 35 | return $this->handlingSignal; | ||
| 36 | } | ||
| 37 | |||
| 38 | public function setExitCode(int $exitCode): void | ||
| 39 | { | ||
| 40 | if ($exitCode < 0 || $exitCode > 255) { | ||
| 41 | throw new \InvalidArgumentException('Exit code must be between 0 and 255.'); | ||
| 42 | } | ||
| 43 | |||
| 44 | $this->exitCode = $exitCode; | ||
| 45 | } | ||
| 46 | |||
| 47 | public function abortExit(): void | ||
| 48 | { | ||
| 49 | $this->exitCode = false; | ||
| 50 | } | ||
| 51 | |||
| 52 | public function getExitCode(): int|false | ||
| 53 | { | ||
| 54 | return $this->exitCode; | ||
| 55 | } | ||
| 56 | } | ||
diff --git a/vendor/symfony/console/Event/ConsoleTerminateEvent.php b/vendor/symfony/console/Event/ConsoleTerminateEvent.php new file mode 100644 index 0000000..38f7253 --- /dev/null +++ b/vendor/symfony/console/Event/ConsoleTerminateEvent.php | |||
| @@ -0,0 +1,50 @@ | |||
| 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 | |||
| 12 | namespace Symfony\Component\Console\Event; | ||
| 13 | |||
| 14 | use Symfony\Component\Console\Command\Command; | ||
| 15 | use Symfony\Component\Console\Input\InputInterface; | ||
| 16 | use Symfony\Component\Console\Output\OutputInterface; | ||
| 17 | |||
| 18 | /** | ||
| 19 | * Allows to manipulate the exit code of a command after its execution. | ||
| 20 | * | ||
| 21 | * @author Francesco Levorato <git@flevour.net> | ||
| 22 | * @author Jules Pietri <jules@heahprod.com> | ||
| 23 | */ | ||
| 24 | final class ConsoleTerminateEvent extends ConsoleEvent | ||
| 25 | { | ||
| 26 | public function __construct( | ||
| 27 | Command $command, | ||
| 28 | InputInterface $input, | ||
| 29 | OutputInterface $output, | ||
| 30 | private int $exitCode, | ||
| 31 | private readonly ?int $interruptingSignal = null, | ||
| 32 | ) { | ||
| 33 | parent::__construct($command, $input, $output); | ||
| 34 | } | ||
| 35 | |||
| 36 | public function setExitCode(int $exitCode): void | ||
| 37 | { | ||
| 38 | $this->exitCode = $exitCode; | ||
| 39 | } | ||
| 40 | |||
| 41 | public function getExitCode(): int | ||
| 42 | { | ||
| 43 | return $this->exitCode; | ||
| 44 | } | ||
| 45 | |||
| 46 | public function getInterruptingSignal(): ?int | ||
| 47 | { | ||
| 48 | return $this->interruptingSignal; | ||
| 49 | } | ||
| 50 | } | ||
