upgrade to laravel 7 and set branch to v2
This commit is contained in:
128
vendor/symfony/process/Process.php
vendored
128
vendor/symfony/process/Process.php
vendored
@@ -71,6 +71,7 @@ class Process implements \IteratorAggregate
|
||||
private $incrementalErrorOutputOffset = 0;
|
||||
private $tty = false;
|
||||
private $pty;
|
||||
private $options = ['suppress_errors' => true, 'bypass_shell' => true];
|
||||
|
||||
private $useFileHandles = false;
|
||||
/** @var PipesInterface */
|
||||
@@ -137,16 +138,12 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* @throws LogicException When proc_open is not installed
|
||||
*/
|
||||
public function __construct($command, string $cwd = null, array $env = null, $input = null, ?float $timeout = 60)
|
||||
public function __construct(array $command, string $cwd = null, array $env = null, $input = null, ?float $timeout = 60)
|
||||
{
|
||||
if (!\function_exists('proc_open')) {
|
||||
throw new LogicException('The Process class relies on proc_open, which is not available on your PHP installation.');
|
||||
}
|
||||
|
||||
if (!\is_array($command)) {
|
||||
@trigger_error(sprintf('Passing a command as string when creating a "%s" instance is deprecated since Symfony 4.2, pass it as an array of its arguments instead, or use the "Process::fromShellCommandline()" constructor if you need features provided by the shell.', __CLASS__), \E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
$this->commandline = $command;
|
||||
$this->cwd = $cwd;
|
||||
|
||||
@@ -200,7 +197,11 @@ class Process implements \IteratorAggregate
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
$this->stop(0);
|
||||
if ($this->options['create_new_console'] ?? false) {
|
||||
$this->processPipes->close();
|
||||
} else {
|
||||
$this->stop(0);
|
||||
}
|
||||
}
|
||||
|
||||
public function __clone()
|
||||
@@ -307,10 +308,7 @@ class Process implements \IteratorAggregate
|
||||
$commandline = $this->replacePlaceholders($commandline, $env);
|
||||
}
|
||||
|
||||
$options = ['suppress_errors' => true];
|
||||
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$options['bypass_shell'] = true;
|
||||
$commandline = $this->prepareWindowsCommandLine($commandline, $env);
|
||||
} elseif (!$this->useFileHandles && $this->isSigchildEnabled()) {
|
||||
// last exit code is output on the fourth pipe and caught to work around --enable-sigchild
|
||||
@@ -336,7 +334,7 @@ class Process implements \IteratorAggregate
|
||||
throw new RuntimeException(sprintf('The provided cwd "%s" does not exist.', $this->cwd));
|
||||
}
|
||||
|
||||
$this->process = @proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $envPairs, $options);
|
||||
$this->process = @proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $envPairs, $this->options);
|
||||
|
||||
if (!\is_resource($this->process)) {
|
||||
throw new RuntimeException('Unable to launch a new process.');
|
||||
@@ -498,7 +496,7 @@ class Process implements \IteratorAggregate
|
||||
* @throws RuntimeException In case --enable-sigchild is activated and the process can't be killed
|
||||
* @throws RuntimeException In case of failure
|
||||
*/
|
||||
public function signal($signal)
|
||||
public function signal(int $signal)
|
||||
{
|
||||
$this->doSignal($signal, true);
|
||||
|
||||
@@ -609,7 +607,7 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* @return \Generator
|
||||
*/
|
||||
public function getIterator($flags = 0)
|
||||
public function getIterator(int $flags = 0)
|
||||
{
|
||||
$this->readPipesForOutput(__FUNCTION__, false);
|
||||
|
||||
@@ -900,7 +898,7 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* @return int|null The exit-code of the process or null if it's not running
|
||||
*/
|
||||
public function stop($timeout = 10, $signal = null)
|
||||
public function stop(float $timeout = 10, int $signal = null)
|
||||
{
|
||||
$timeoutMicro = microtime(true) + $timeout;
|
||||
if ($this->isRunning()) {
|
||||
@@ -977,24 +975,6 @@ class Process implements \IteratorAggregate
|
||||
return \is_array($this->commandline) ? implode(' ', array_map([$this, 'escapeArgument'], $this->commandline)) : $this->commandline;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the command line to be executed.
|
||||
*
|
||||
* @param string|array $commandline The command to execute
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @deprecated since Symfony 4.2.
|
||||
*/
|
||||
public function setCommandLine($commandline)
|
||||
{
|
||||
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2.', __METHOD__), \E_USER_DEPRECATED);
|
||||
|
||||
$this->commandline = $commandline;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the process timeout (max. runtime).
|
||||
*
|
||||
@@ -1020,13 +1000,11 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* To disable the timeout, set this value to null.
|
||||
*
|
||||
* @param int|float|null $timeout The timeout in seconds
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws InvalidArgumentException if the timeout is negative
|
||||
*/
|
||||
public function setTimeout($timeout)
|
||||
public function setTimeout(?float $timeout)
|
||||
{
|
||||
$this->timeout = $this->validateTimeout($timeout);
|
||||
|
||||
@@ -1034,18 +1012,16 @@ class Process implements \IteratorAggregate
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the process idle timeout (max. time since last output).
|
||||
* Sets the process idle timeout (max. time since last output) in seconds.
|
||||
*
|
||||
* To disable the timeout, set this value to null.
|
||||
*
|
||||
* @param int|float|null $timeout The timeout in seconds
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws LogicException if the output is disabled
|
||||
* @throws InvalidArgumentException if the timeout is negative
|
||||
*/
|
||||
public function setIdleTimeout($timeout)
|
||||
public function setIdleTimeout(?float $timeout)
|
||||
{
|
||||
if (null !== $timeout && $this->outputDisabled) {
|
||||
throw new LogicException('Idle timeout can not be set while the output is disabled.');
|
||||
@@ -1059,13 +1035,11 @@ class Process implements \IteratorAggregate
|
||||
/**
|
||||
* Enables or disables the TTY mode.
|
||||
*
|
||||
* @param bool $tty True to enabled and false to disable
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws RuntimeException In case the TTY mode is not supported
|
||||
*/
|
||||
public function setTty($tty)
|
||||
public function setTty(bool $tty)
|
||||
{
|
||||
if ('\\' === \DIRECTORY_SEPARATOR && $tty) {
|
||||
throw new RuntimeException('TTY mode is not supported on Windows platform.');
|
||||
@@ -1075,7 +1049,7 @@ class Process implements \IteratorAggregate
|
||||
throw new RuntimeException('TTY mode requires /dev/tty to be read/writable.');
|
||||
}
|
||||
|
||||
$this->tty = (bool) $tty;
|
||||
$this->tty = $tty;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -1093,13 +1067,11 @@ class Process implements \IteratorAggregate
|
||||
/**
|
||||
* Sets PTY mode.
|
||||
*
|
||||
* @param bool $bool
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPty($bool)
|
||||
public function setPty(bool $bool)
|
||||
{
|
||||
$this->pty = (bool) $bool;
|
||||
$this->pty = $bool;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -1133,11 +1105,9 @@ class Process implements \IteratorAggregate
|
||||
/**
|
||||
* Sets the current working directory.
|
||||
*
|
||||
* @param string $cwd The new working directory
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setWorkingDirectory($cwd)
|
||||
public function setWorkingDirectory(string $cwd)
|
||||
{
|
||||
$this->cwd = $cwd;
|
||||
|
||||
@@ -1213,26 +1183,6 @@ class Process implements \IteratorAggregate
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether environment variables will be inherited or not.
|
||||
*
|
||||
* @param bool $inheritEnv
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @deprecated since Symfony 4.4, env variables are always inherited
|
||||
*/
|
||||
public function inheritEnvironmentVariables($inheritEnv = true)
|
||||
{
|
||||
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.4, env variables are always inherited.', __METHOD__), \E_USER_DEPRECATED);
|
||||
|
||||
if (!$inheritEnv) {
|
||||
throw new InvalidArgumentException('Not inheriting environment variables is not supported.');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a check between the timeout definition and the time the process started.
|
||||
*
|
||||
@@ -1260,6 +1210,44 @@ class Process implements \IteratorAggregate
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws LogicException in case process is not started
|
||||
*/
|
||||
public function getStartTime(): float
|
||||
{
|
||||
if (!$this->isStarted()) {
|
||||
throw new LogicException('Start time is only available after process start.');
|
||||
}
|
||||
|
||||
return $this->starttime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines options to pass to the underlying proc_open().
|
||||
*
|
||||
* @see https://php.net/proc_open for the options supported by PHP.
|
||||
*
|
||||
* Enabling the "create_new_console" option allows a subprocess to continue
|
||||
* to run after the main process exited, on both Windows and *nix
|
||||
*/
|
||||
public function setOptions(array $options)
|
||||
{
|
||||
if ($this->isRunning()) {
|
||||
throw new RuntimeException('Setting options while the process is running is not possible.');
|
||||
}
|
||||
|
||||
$defaultOptions = $this->options;
|
||||
$existingOptions = ['blocking_pipes', 'create_process_group', 'create_new_console'];
|
||||
|
||||
foreach ($options as $key => $value) {
|
||||
if (!\in_array($key, $existingOptions)) {
|
||||
$this->options = $defaultOptions;
|
||||
throw new LogicException(sprintf('Invalid option "%s" passed to "%s()". Supported options are "%s".', $key, __METHOD__, implode('", "', $existingOptions)));
|
||||
}
|
||||
$this->options[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether TTY is supported on the current operating system.
|
||||
*/
|
||||
@@ -1347,7 +1335,7 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* @param bool $blocking Whether to use a blocking read call
|
||||
*/
|
||||
protected function updateStatus($blocking)
|
||||
protected function updateStatus(bool $blocking)
|
||||
{
|
||||
if (self::STATUS_STARTED !== $this->status) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user