ConsoleTerminateEvent.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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\Event;
  11. use Symfony\Component\Console\Command\Command;
  12. use Symfony\Component\Console\Input\InputInterface;
  13. use Symfony\Component\Console\Output\OutputInterface;
  14. /**
  15. * Allows to manipulate the exit code of a command after its execution.
  16. *
  17. * @author Francesco Levorato <git@flevour.net>
  18. * @author Jules Pietri <jules@heahprod.com>
  19. */
  20. final class ConsoleTerminateEvent extends ConsoleEvent
  21. {
  22. public function __construct(
  23. Command $command,
  24. InputInterface $input,
  25. OutputInterface $output,
  26. private int $exitCode,
  27. private readonly ?int $interruptingSignal = null,
  28. ) {
  29. parent::__construct($command, $input, $output);
  30. }
  31. public function setExitCode(int $exitCode): void
  32. {
  33. $this->exitCode = $exitCode;
  34. }
  35. public function getExitCode(): int
  36. {
  37. return $this->exitCode;
  38. }
  39. public function getInterruptingSignal(): ?int
  40. {
  41. return $this->interruptingSignal;
  42. }
  43. }