Пример #1
0
 public function __construct(Process $process)
 {
     if ($process->isSuccessful()) {
         throw new \InvalidArgumentException('Expected a failed process, but the given process was successful.');
     }
     $error = sprintf('The command "%s" failed.' . "\nExit Code: %s(%s)", $process->getCommandLine(), $process->getExitCode(), $process->getExitCodeText());
     if (!$process->isOutputDisabled()) {
         $error .= sprintf("\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s", $process->getOutput(), $process->getErrorOutput());
     }
     parent::__construct($error);
     $this->process = $process;
 }
Пример #2
0
 /**
  * 创建一个Process实例
  * @return Process
  */
 public function getProcess()
 {
     if (0 === count($this->prefix) && 0 === count($this->arguments)) {
         throw new \LogicException('You must add() command arguments before calling getProcess().');
     }
     $options = $this->options;
     $arguments = array_merge($this->prefix, $this->arguments);
     $script = implode(' ', array_map([__NAMESPACE__ . '\\Utils', 'escapeArgument'], $arguments));
     if ($this->inheritEnv) {
         // include $_ENV for BC purposes
         $env = array_replace($_ENV, $_SERVER, $this->env);
     } else {
         $env = $this->env;
     }
     $process = new Process($script, $this->cwd, $env, $this->input, $this->timeout, $options);
     if ($this->outputDisabled) {
         $process->disableOutput();
     }
     return $process;
 }
Пример #3
0
 /**
  * 创建一个新的 UnixPipes 实例
  * @param Process         $process
  * @param string|resource $input
  * @return self
  */
 public static function create(Process $process, $input)
 {
     return new static($process->isTty(), $process->isPty(), $input, $process->isOutputDisabled());
 }
Пример #4
0
 public function __construct(Process $process, $timeoutType)
 {
     $this->process = $process;
     $this->timeoutType = $timeoutType;
     parent::__construct(sprintf('The process "%s" exceeded the timeout of %s seconds.', $process->getCommandLine(), $this->getExceededTimeout()));
 }