[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/symfony/console/Event/ -> ConsoleErrorEvent.php (source)

   1  <?php
   2  
   3  /*
   4   * This file is part of the Symfony package.
   5   *
   6   * (c) Fabien Potencier <[email protected]>
   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 <[email protected]>
  22   */
  23  final class ConsoleErrorEvent extends ConsoleEvent
  24  {
  25      private $error;
  26      private $exitCode;
  27  
  28      public function __construct(InputInterface $input, OutputInterface $output, \Throwable $error, Command $command = null)
  29      {
  30          parent::__construct($command, $input, $output);
  31  
  32          $this->error = $error;
  33      }
  34  
  35      public function getError(): \Throwable
  36      {
  37          return $this->error;
  38      }
  39  
  40      public function setError(\Throwable $error): void
  41      {
  42          $this->error = $error;
  43      }
  44  
  45      public function setExitCode(int $exitCode): void
  46      {
  47          $this->exitCode = $exitCode;
  48  
  49          $r = new \ReflectionProperty($this->error, 'code');
  50          $r->setAccessible(true);
  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  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer