RunProcessContext.php 936 B

123456789101112131415161718192021222324252627282930313233
  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\Process\Messenger;
  11. use Symfony\Component\Process\Process;
  12. /**
  13. * @author Kevin Bond <kevinbond@gmail.com>
  14. */
  15. final class RunProcessContext
  16. {
  17. public readonly ?int $exitCode;
  18. public readonly ?string $output;
  19. public readonly ?string $errorOutput;
  20. public function __construct(
  21. public readonly RunProcessMessage $message,
  22. Process $process,
  23. ) {
  24. $this->exitCode = $process->getExitCode();
  25. $this->output = !$process->isStarted() || $process->isOutputDisabled() ? null : $process->getOutput();
  26. $this->errorOutput = !$process->isStarted() || $process->isOutputDisabled() ? null : $process->getErrorOutput();
  27. }
  28. }