diff options
| author | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
| commit | bf6655a534a6775d30cafa67bd801276bda1d98d (patch) | |
| tree | c6381e3f6c81c33eab72508f410b165ba05f7e9c /vendor/symfony/console/Event/ConsoleErrorEvent.php | |
| parent | 94d67a4b51f8e62e7d518cce26a526ae1ec48278 (diff) | |
| download | AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.tar.gz AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.tar.bz2 AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.zip | |
VERSION 0.2 doctrine ORM et entités
Diffstat (limited to 'vendor/symfony/console/Event/ConsoleErrorEvent.php')
| -rw-r--r-- | vendor/symfony/console/Event/ConsoleErrorEvent.php | 58 |
1 files changed, 58 insertions, 0 deletions
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 | } | ||
