composer update

This commit is contained in:
2019-12-01 06:37:45 +00:00
parent fa199eef05
commit 3115ab75a5
3650 changed files with 72361 additions and 147137 deletions

View File

@@ -69,7 +69,7 @@ class Process implements \IteratorAggregate
private $status = self::STATUS_READY;
private $incrementalOutputOffset = 0;
private $incrementalErrorOutputOffset = 0;
private $tty;
private $tty = false;
private $pty;
private $useFileHandles = false;
@@ -152,8 +152,8 @@ class Process implements \IteratorAggregate
// on Windows, if the cwd changed via chdir(), proc_open defaults to the dir where PHP was started
// on Gnu/Linux, PHP builds with --enable-maintainer-zts are also affected
// @see : https://bugs.php.net/bug.php?id=51800
// @see : https://bugs.php.net/bug.php?id=50524
// @see : https://bugs.php.net/51800
// @see : https://bugs.php.net/50524
if (null === $this->cwd && (\defined('ZEND_THREAD_SAFE') || '\\' === \DIRECTORY_SEPARATOR)) {
$this->cwd = getcwd();
}
@@ -186,6 +186,8 @@ class Process implements \IteratorAggregate
* @param mixed|null $input The input as stream resource, scalar or \Traversable, or null for no input
* @param int|float|null $timeout The timeout in seconds or null to disable
*
* @return static
*
* @throws RuntimeException When proc_open is not installed
*/
public static function fromShellCommandline(string $command, string $cwd = null, array $env = null, $input = null, ?float $timeout = 60)
@@ -218,7 +220,6 @@ class Process implements \IteratorAggregate
*
* @param callable|null $callback A PHP callback to run whenever there is some
* output available on STDOUT or STDERR
* @param array $env An array of additional env vars to set when running the process
*
* @return int The exit status code
*
@@ -241,16 +242,13 @@ class Process implements \IteratorAggregate
* This is identical to run() except that an exception is thrown if the process
* exits with a non-zero exit code.
*
* @param callable|null $callback
* @param array $env An array of additional env vars to set when running the process
*
* @return self
* @return $this
*
* @throws ProcessFailedException if the process didn't terminate successfully
*
* @final
*/
public function mustRun(callable $callback = null, array $env = [])
public function mustRun(callable $callback = null, array $env = []): self
{
if (0 !== $this->run($callback, $env)) {
throw new ProcessFailedException($this);
@@ -273,7 +271,6 @@ class Process implements \IteratorAggregate
*
* @param callable|null $callback A PHP callback to run whenever there is some
* output available on STDOUT or STDERR
* @param array $env An array of additional env vars to set when running the process
*
* @throws RuntimeException When process can't be launched
* @throws RuntimeException When process is already running
@@ -291,6 +288,12 @@ class Process implements \IteratorAggregate
$this->hasCallback = null !== $callback;
$descriptors = $this->getDescriptors();
if ($this->env) {
$env += $this->env;
}
$env += $this->getDefaultEnv();
if (\is_array($commandline = $this->commandline)) {
$commandline = implode(' ', array_map([$this, 'escapeArgument'], $commandline));
@@ -298,13 +301,10 @@ class Process implements \IteratorAggregate
// exec is mandatory to deal with sending a signal to the process
$commandline = 'exec '.$commandline;
}
} else {
$commandline = $this->replacePlaceholders($commandline, $env);
}
if ($this->env) {
$env += $this->env;
}
$env += $this->getDefaultEnv();
$options = ['suppress_errors' => true];
if ('\\' === \DIRECTORY_SEPARATOR) {
@@ -360,9 +360,8 @@ class Process implements \IteratorAggregate
*
* @param callable|null $callback A PHP callback to run whenever there is some
* output available on STDOUT or STDERR
* @param array $env An array of additional env vars to set when running the process
*
* @return $this
* @return static
*
* @throws RuntimeException When process can't be launched
* @throws RuntimeException When process is already running
@@ -371,7 +370,7 @@ class Process implements \IteratorAggregate
*
* @final
*/
public function restart(callable $callback = null, array $env = [])
public function restart(callable $callback = null, array $env = []): self
{
if ($this->isRunning()) {
throw new RuntimeException('Process is already running');
@@ -488,7 +487,7 @@ class Process implements \IteratorAggregate
/**
* Sends a POSIX signal to the process.
*
* @param int $signal A valid POSIX signal (see http://www.php.net/manual/en/pcntl.constants.php)
* @param int $signal A valid POSIX signal (see https://php.net/pcntl.constants)
*
* @return $this
*
@@ -753,7 +752,7 @@ class Process implements \IteratorAggregate
public function getExitCodeText()
{
if (null === $exitcode = $this->getExitCode()) {
return;
return null;
}
return isset(self::$exitCodes[$exitcode]) ? self::$exitCodes[$exitcode] : 'Unknown error';
@@ -896,7 +895,7 @@ class Process implements \IteratorAggregate
* @param int|float $timeout The timeout in seconds
* @param int $signal A POSIX signal to send in case the process has not stop at timeout, default is SIGKILL (9)
*
* @return int The exit-code of the process
* @return int|null The exit-code of the process or null if it's not running
*/
public function stop($timeout = 10, $signal = null)
{
@@ -955,6 +954,16 @@ class Process implements \IteratorAggregate
fseek($this->stderr, $this->incrementalErrorOutputOffset);
}
/**
* Gets the last output time in seconds.
*
* @return float|null The last output time in seconds or null if it isn't started
*/
public function getLastOutputTime(): ?float
{
return $this->lastOutputTime;
}
/**
* Gets the command line to be executed.
*
@@ -970,7 +979,7 @@ class Process implements \IteratorAggregate
*
* @param string|array $commandline The command to execute
*
* @return self The current Process instance
* @return $this
*
* @deprecated since Symfony 4.2.
*/
@@ -1004,13 +1013,13 @@ class Process implements \IteratorAggregate
}
/**
* Sets the process timeout (max. runtime).
* Sets the process timeout (max. runtime) in seconds.
*
* To disable the timeout, set this value to null.
*
* @param int|float|null $timeout The timeout in seconds
*
* @return self The current Process instance
* @return $this
*
* @throws InvalidArgumentException if the timeout is negative
*/
@@ -1028,7 +1037,7 @@ class Process implements \IteratorAggregate
*
* @param int|float|null $timeout The timeout in seconds
*
* @return self The current Process instance
* @return $this
*
* @throws LogicException if the output is disabled
* @throws InvalidArgumentException if the timeout is negative
@@ -1049,7 +1058,7 @@ class Process implements \IteratorAggregate
*
* @param bool $tty True to enabled and false to disable
*
* @return self The current Process instance
* @return $this
*
* @throws RuntimeException In case the TTY mode is not supported
*/
@@ -1083,7 +1092,7 @@ class Process implements \IteratorAggregate
*
* @param bool $bool
*
* @return self
* @return $this
*/
public function setPty($bool)
{
@@ -1123,7 +1132,7 @@ class Process implements \IteratorAggregate
*
* @param string $cwd The new working directory
*
* @return self The current Process instance
* @return $this
*/
public function setWorkingDirectory($cwd)
{
@@ -1155,7 +1164,7 @@ class Process implements \IteratorAggregate
*
* @param array $env The new environment variables
*
* @return self The current Process instance
* @return $this
*/
public function setEnv(array $env)
{
@@ -1186,7 +1195,7 @@ class Process implements \IteratorAggregate
*
* @param string|int|float|bool|resource|\Traversable|null $input The content
*
* @return self The current Process instance
* @return $this
*
* @throws LogicException In case the process is running
*/
@@ -1206,10 +1215,14 @@ class Process implements \IteratorAggregate
*
* @param bool $inheritEnv
*
* @return self The current Process instance
* @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.');
}
@@ -1308,25 +1321,21 @@ class Process implements \IteratorAggregate
protected function buildCallback(callable $callback = null)
{
if ($this->outputDisabled) {
return function ($type, $data) use ($callback) {
if (null !== $callback) {
return $callback($type, $data);
}
return function ($type, $data) use ($callback): bool {
return null !== $callback && $callback($type, $data);
};
}
$out = self::OUT;
return function ($type, $data) use ($callback, $out) {
return function ($type, $data) use ($callback, $out): bool {
if ($out == $type) {
$this->addOutput($data);
} else {
$this->addErrorOutput($data);
}
if (null !== $callback) {
return $callback($type, $data);
}
return null !== $callback && $callback($type, $data);
};
}
@@ -1487,7 +1496,7 @@ class Process implements \IteratorAggregate
/**
* Sends a POSIX signal to the process.
*
* @param int $signal A valid POSIX signal (see http://www.php.net/manual/en/pcntl.constants.php)
* @param int $signal A valid POSIX signal (see https://php.net/pcntl.constants)
* @param bool $throwException Whether to throw exception in case signal failed
*
* @return bool True if the signal was sent successfully, false otherwise
@@ -1540,7 +1549,7 @@ class Process implements \IteratorAggregate
return true;
}
private function prepareWindowsCommandLine(string $cmd, array &$env)
private function prepareWindowsCommandLine(string $cmd, array &$env): string
{
$uid = uniqid('', true);
$varCount = 0;
@@ -1632,7 +1641,18 @@ class Process implements \IteratorAggregate
return '"'.str_replace(['"', '^', '%', '!', "\n"], ['""', '"^^"', '"^%"', '"^!"', '!LF!'], $argument).'"';
}
private function getDefaultEnv()
private function replacePlaceholders(string $commandline, array $env)
{
return preg_replace_callback('/"\$([_a-zA-Z]++[_a-zA-Z0-9]*+)"/', function ($matches) use ($commandline, $env) {
if (!isset($env[$matches[1]]) || false === $env[$matches[1]]) {
throw new InvalidArgumentException(sprintf('Command line is missing a value for key %s: %s.', $matches[0], $commandline));
}
return '\\' === \DIRECTORY_SEPARATOR ? $this->escapeArgument($env[$matches[1]]) : $matches[0];
}, $commandline);
}
private function getDefaultEnv(): array
{
$env = [];