Laravel 5.6 updates
Travis config update Removed HHVM script as Laravel no longer support HHVM after releasing 5.3
This commit is contained in:
303
vendor/symfony/process/Process.php
vendored
303
vendor/symfony/process/Process.php
vendored
@@ -14,6 +14,7 @@ namespace Symfony\Component\Process;
|
||||
use Symfony\Component\Process\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Process\Exception\LogicException;
|
||||
use Symfony\Component\Process\Exception\ProcessFailedException;
|
||||
use Symfony\Component\Process\Exception\ProcessSignaledException;
|
||||
use Symfony\Component\Process\Exception\ProcessTimedOutException;
|
||||
use Symfony\Component\Process\Exception\RuntimeException;
|
||||
use Symfony\Component\Process\Pipes\PipesInterface;
|
||||
@@ -58,22 +59,18 @@ class Process implements \IteratorAggregate
|
||||
private $lastOutputTime;
|
||||
private $timeout;
|
||||
private $idleTimeout;
|
||||
private $options = array('suppress_errors' => true);
|
||||
private $exitcode;
|
||||
private $fallbackStatus = array();
|
||||
private $processInformation;
|
||||
private $outputDisabled = false;
|
||||
private $stdout;
|
||||
private $stderr;
|
||||
private $enhanceWindowsCompatibility = true;
|
||||
private $enhanceSigchildCompatibility;
|
||||
private $process;
|
||||
private $status = self::STATUS_READY;
|
||||
private $incrementalOutputOffset = 0;
|
||||
private $incrementalErrorOutputOffset = 0;
|
||||
private $tty;
|
||||
private $pty;
|
||||
private $inheritEnv = false;
|
||||
|
||||
private $useFileHandles = false;
|
||||
/** @var PipesInterface */
|
||||
@@ -137,11 +134,10 @@ class Process implements \IteratorAggregate
|
||||
* @param array|null $env The environment variables or null to use the same environment as the current PHP process
|
||||
* @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
|
||||
* @param array $options An array of options for proc_open
|
||||
*
|
||||
* @throws RuntimeException When proc_open is not installed
|
||||
*/
|
||||
public function __construct($commandline, $cwd = null, array $env = null, $input = null, $timeout = 60, array $options = null)
|
||||
public function __construct($commandline, string $cwd = null, array $env = null, $input = null, ?float $timeout = 60)
|
||||
{
|
||||
if (!\function_exists('proc_open')) {
|
||||
throw new RuntimeException('The Process class relies on proc_open, which is not available on your PHP installation.');
|
||||
@@ -165,11 +161,6 @@ class Process implements \IteratorAggregate
|
||||
$this->setTimeout($timeout);
|
||||
$this->useFileHandles = '\\' === \DIRECTORY_SEPARATOR;
|
||||
$this->pty = false;
|
||||
$this->enhanceSigchildCompatibility = '\\' !== \DIRECTORY_SEPARATOR && $this->isSigchildEnabled();
|
||||
if (null !== $options) {
|
||||
@trigger_error(sprintf('The $options parameter of the %s constructor is deprecated since Symfony 3.3 and will be removed in 4.0.', __CLASS__), E_USER_DEPRECATED);
|
||||
$this->options = array_replace($this->options, $options);
|
||||
}
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
@@ -202,11 +193,10 @@ class Process implements \IteratorAggregate
|
||||
* @throws RuntimeException When process stopped after receiving signal
|
||||
* @throws LogicException In case a callback is provided and output has been disabled
|
||||
*
|
||||
* @final since version 3.3
|
||||
* @final
|
||||
*/
|
||||
public function run($callback = null/*, array $env = array()*/)
|
||||
public function run(callable $callback = null, array $env = array()): int
|
||||
{
|
||||
$env = 1 < \func_num_args() ? func_get_arg(1) : null;
|
||||
$this->start($callback, $env);
|
||||
|
||||
return $this->wait();
|
||||
@@ -223,18 +213,12 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* @return self
|
||||
*
|
||||
* @throws RuntimeException if PHP was compiled with --enable-sigchild and the enhanced sigchild compatibility mode is not enabled
|
||||
* @throws ProcessFailedException if the process didn't terminate successfully
|
||||
*
|
||||
* @final since version 3.3
|
||||
* @final
|
||||
*/
|
||||
public function mustRun(callable $callback = null/*, array $env = array()*/)
|
||||
public function mustRun(callable $callback = null, array $env = array())
|
||||
{
|
||||
if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
|
||||
throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.');
|
||||
}
|
||||
$env = 1 < \func_num_args() ? func_get_arg(1) : null;
|
||||
|
||||
if (0 !== $this->run($callback, $env)) {
|
||||
throw new ProcessFailedException($this);
|
||||
}
|
||||
@@ -262,29 +246,17 @@ class Process implements \IteratorAggregate
|
||||
* @throws RuntimeException When process is already running
|
||||
* @throws LogicException In case a callback is provided and output has been disabled
|
||||
*/
|
||||
public function start(callable $callback = null/*, array $env = array()*/)
|
||||
public function start(callable $callback = null, array $env = array())
|
||||
{
|
||||
if ($this->isRunning()) {
|
||||
throw new RuntimeException('Process is already running');
|
||||
}
|
||||
if (2 <= \func_num_args()) {
|
||||
$env = func_get_arg(1);
|
||||
} else {
|
||||
if (__CLASS__ !== static::class) {
|
||||
$r = new \ReflectionMethod($this, __FUNCTION__);
|
||||
if (__CLASS__ !== $r->getDeclaringClass()->getName() && (2 > $r->getNumberOfParameters() || 'env' !== $r->getParameters()[1]->name)) {
|
||||
@trigger_error(sprintf('The %s::start() method expects a second "$env" argument since Symfony 3.3. It will be made mandatory in 4.0.', static::class), E_USER_DEPRECATED);
|
||||
}
|
||||
}
|
||||
$env = null;
|
||||
}
|
||||
|
||||
$this->resetProcessData();
|
||||
$this->starttime = $this->lastOutputTime = microtime(true);
|
||||
$this->callback = $this->buildCallback($callback);
|
||||
$this->hasCallback = null !== $callback;
|
||||
$descriptors = $this->getDescriptors();
|
||||
$inheritEnv = $this->inheritEnv;
|
||||
|
||||
if (\is_array($commandline = $this->commandline)) {
|
||||
$commandline = implode(' ', array_map(array($this, 'escapeArgument'), $commandline));
|
||||
@@ -295,26 +267,17 @@ class Process implements \IteratorAggregate
|
||||
}
|
||||
}
|
||||
|
||||
if (null === $env) {
|
||||
$env = $this->env;
|
||||
} else {
|
||||
if ($this->env) {
|
||||
$env += $this->env;
|
||||
}
|
||||
$inheritEnv = true;
|
||||
if ($this->env) {
|
||||
$env += $this->env;
|
||||
}
|
||||
$env += $this->getDefaultEnv();
|
||||
|
||||
if (null !== $env && $inheritEnv) {
|
||||
$env += $this->getDefaultEnv();
|
||||
} elseif (null !== $env) {
|
||||
@trigger_error('Not inheriting environment variables is deprecated since Symfony 3.3 and will always happen in 4.0. Set "Process::inheritEnvironmentVariables()" to true instead.', E_USER_DEPRECATED);
|
||||
} else {
|
||||
$env = $this->getDefaultEnv();
|
||||
}
|
||||
if ('\\' === \DIRECTORY_SEPARATOR && $this->enhanceWindowsCompatibility) {
|
||||
$this->options['bypass_shell'] = true;
|
||||
$options = array('suppress_errors' => true);
|
||||
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$options['bypass_shell'] = true;
|
||||
$commandline = $this->prepareWindowsCommandLine($commandline, $env);
|
||||
} elseif (!$this->useFileHandles && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
|
||||
} elseif (!$this->useFileHandles && $this->isSigchildEnabled()) {
|
||||
// last exit code is output on the fourth pipe and caught to work around --enable-sigchild
|
||||
$descriptors[3] = array('pipe', 'w');
|
||||
|
||||
@@ -326,22 +289,19 @@ class Process implements \IteratorAggregate
|
||||
// @see : https://bugs.php.net/69442
|
||||
$ptsWorkaround = fopen(__FILE__, 'r');
|
||||
}
|
||||
if (\defined('HHVM_VERSION')) {
|
||||
$envPairs = $env;
|
||||
} else {
|
||||
$envPairs = array();
|
||||
foreach ($env as $k => $v) {
|
||||
if (false !== $v) {
|
||||
$envPairs[] = $k.'='.$v;
|
||||
}
|
||||
|
||||
$envPairs = array();
|
||||
foreach ($env as $k => $v) {
|
||||
if (false !== $v) {
|
||||
$envPairs[] = $k.'='.$v;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_dir($this->cwd)) {
|
||||
@trigger_error('The provided cwd does not exist. Command is currently ran against getcwd(). This behavior is deprecated since Symfony 3.4 and will be removed in 4.0.', E_USER_DEPRECATED);
|
||||
throw new RuntimeException('The provided cwd does not exist.');
|
||||
}
|
||||
|
||||
$this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $envPairs, $this->options);
|
||||
$this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $envPairs, $options);
|
||||
|
||||
if (!\is_resource($this->process)) {
|
||||
throw new RuntimeException('Unable to launch a new process.');
|
||||
@@ -376,14 +336,13 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* @see start()
|
||||
*
|
||||
* @final since version 3.3
|
||||
* @final
|
||||
*/
|
||||
public function restart(callable $callback = null/*, array $env = array()*/)
|
||||
public function restart(callable $callback = null, array $env = array())
|
||||
{
|
||||
if ($this->isRunning()) {
|
||||
throw new RuntimeException('Process is already running');
|
||||
}
|
||||
$env = 1 < \func_num_args() ? func_get_arg(1) : null;
|
||||
|
||||
$process = clone $this;
|
||||
$process->start($callback, $env);
|
||||
@@ -431,7 +390,7 @@ class Process implements \IteratorAggregate
|
||||
}
|
||||
|
||||
if ($this->processInformation['signaled'] && $this->processInformation['termsig'] !== $this->latestSignal) {
|
||||
throw new RuntimeException(sprintf('The process has been signaled with signal "%s".', $this->processInformation['termsig']));
|
||||
throw new ProcessSignaledException($this);
|
||||
}
|
||||
|
||||
return $this->exitcode;
|
||||
@@ -693,15 +652,9 @@ class Process implements \IteratorAggregate
|
||||
* Returns the exit code returned by the process.
|
||||
*
|
||||
* @return null|int The exit status code, null if the Process is not terminated
|
||||
*
|
||||
* @throws RuntimeException In case --enable-sigchild is activated and the sigchild compatibility mode is disabled
|
||||
*/
|
||||
public function getExitCode()
|
||||
{
|
||||
if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
|
||||
throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.');
|
||||
}
|
||||
|
||||
$this->updateStatus(false);
|
||||
|
||||
return $this->exitcode;
|
||||
@@ -744,17 +697,12 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws RuntimeException In case --enable-sigchild is activated
|
||||
* @throws LogicException In case the process is not terminated
|
||||
* @throws LogicException In case the process is not terminated
|
||||
*/
|
||||
public function hasBeenSignaled()
|
||||
{
|
||||
$this->requireProcessIsTerminated(__FUNCTION__);
|
||||
|
||||
if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
|
||||
throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.');
|
||||
}
|
||||
|
||||
return $this->processInformation['signaled'];
|
||||
}
|
||||
|
||||
@@ -772,7 +720,7 @@ class Process implements \IteratorAggregate
|
||||
{
|
||||
$this->requireProcessIsTerminated(__FUNCTION__);
|
||||
|
||||
if ($this->isSigchildEnabled() && (!$this->enhanceSigchildCompatibility || -1 === $this->processInformation['termsig'])) {
|
||||
if ($this->isSigchildEnabled() && -1 === $this->processInformation['termsig']) {
|
||||
throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.');
|
||||
}
|
||||
|
||||
@@ -904,10 +852,8 @@ class Process implements \IteratorAggregate
|
||||
* Adds a line to the STDOUT stream.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @param string $line The line to append
|
||||
*/
|
||||
public function addOutput($line)
|
||||
public function addOutput(string $line)
|
||||
{
|
||||
$this->lastOutputTime = microtime(true);
|
||||
|
||||
@@ -920,10 +866,8 @@ class Process implements \IteratorAggregate
|
||||
* Adds a line to the STDERR stream.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @param string $line The line to append
|
||||
*/
|
||||
public function addErrorOutput($line)
|
||||
public function addErrorOutput(string $line)
|
||||
{
|
||||
$this->lastOutputTime = microtime(true);
|
||||
|
||||
@@ -1031,16 +975,9 @@ class Process implements \IteratorAggregate
|
||||
if ('\\' === \DIRECTORY_SEPARATOR && $tty) {
|
||||
throw new RuntimeException('TTY mode is not supported on Windows platform.');
|
||||
}
|
||||
if ($tty) {
|
||||
static $isTtySupported;
|
||||
|
||||
if (null === $isTtySupported) {
|
||||
$isTtySupported = (bool) @proc_open('echo 1 >/dev/null', array(array('file', '/dev/tty', 'r'), array('file', '/dev/tty', 'w'), array('file', '/dev/tty', 'w')), $pipes);
|
||||
}
|
||||
|
||||
if (!$isTtySupported) {
|
||||
throw new RuntimeException('TTY mode requires /dev/tty to be read/writable.');
|
||||
}
|
||||
if ($tty && !self::isTtySupported()) {
|
||||
throw new RuntimeException('TTY mode requires /dev/tty to be read/writable.');
|
||||
}
|
||||
|
||||
$this->tty = (bool) $tty;
|
||||
@@ -1181,108 +1118,6 @@ class Process implements \IteratorAggregate
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the options for proc_open.
|
||||
*
|
||||
* @return array The current options
|
||||
*
|
||||
* @deprecated since version 3.3, to be removed in 4.0.
|
||||
*/
|
||||
public function getOptions()
|
||||
{
|
||||
@trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED);
|
||||
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the options for proc_open.
|
||||
*
|
||||
* @param array $options The new options
|
||||
*
|
||||
* @return self The current Process instance
|
||||
*
|
||||
* @deprecated since version 3.3, to be removed in 4.0.
|
||||
*/
|
||||
public function setOptions(array $options)
|
||||
{
|
||||
@trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED);
|
||||
|
||||
$this->options = $options;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether or not Windows compatibility is enabled.
|
||||
*
|
||||
* This is true by default.
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @deprecated since version 3.3, to be removed in 4.0. Enhanced Windows compatibility will always be enabled.
|
||||
*/
|
||||
public function getEnhanceWindowsCompatibility()
|
||||
{
|
||||
@trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0. Enhanced Windows compatibility will always be enabled.', __METHOD__), E_USER_DEPRECATED);
|
||||
|
||||
return $this->enhanceWindowsCompatibility;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether or not Windows compatibility is enabled.
|
||||
*
|
||||
* @param bool $enhance
|
||||
*
|
||||
* @return self The current Process instance
|
||||
*
|
||||
* @deprecated since version 3.3, to be removed in 4.0. Enhanced Windows compatibility will always be enabled.
|
||||
*/
|
||||
public function setEnhanceWindowsCompatibility($enhance)
|
||||
{
|
||||
@trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0. Enhanced Windows compatibility will always be enabled.', __METHOD__), E_USER_DEPRECATED);
|
||||
|
||||
$this->enhanceWindowsCompatibility = (bool) $enhance;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether sigchild compatibility mode is activated or not.
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @deprecated since version 3.3, to be removed in 4.0. Sigchild compatibility will always be enabled.
|
||||
*/
|
||||
public function getEnhanceSigchildCompatibility()
|
||||
{
|
||||
@trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0. Sigchild compatibility will always be enabled.', __METHOD__), E_USER_DEPRECATED);
|
||||
|
||||
return $this->enhanceSigchildCompatibility;
|
||||
}
|
||||
|
||||
/**
|
||||
* Activates sigchild compatibility mode.
|
||||
*
|
||||
* Sigchild compatibility mode is required to get the exit code and
|
||||
* determine the success of a process when PHP has been compiled with
|
||||
* the --enable-sigchild option
|
||||
*
|
||||
* @param bool $enhance
|
||||
*
|
||||
* @return self The current Process instance
|
||||
*
|
||||
* @deprecated since version 3.3, to be removed in 4.0.
|
||||
*/
|
||||
public function setEnhanceSigchildCompatibility($enhance)
|
||||
{
|
||||
@trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0. Sigchild compatibility will always be enabled.', __METHOD__), E_USER_DEPRECATED);
|
||||
|
||||
$this->enhanceSigchildCompatibility = (bool) $enhance;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether environment variables will be inherited or not.
|
||||
*
|
||||
@@ -1293,28 +1128,12 @@ class Process implements \IteratorAggregate
|
||||
public function inheritEnvironmentVariables($inheritEnv = true)
|
||||
{
|
||||
if (!$inheritEnv) {
|
||||
@trigger_error('Not inheriting environment variables is deprecated since Symfony 3.3 and will always happen in 4.0. Set "Process::inheritEnvironmentVariables()" to true instead.', E_USER_DEPRECATED);
|
||||
throw new InvalidArgumentException('Not inheriting environment variables is not supported.');
|
||||
}
|
||||
|
||||
$this->inheritEnv = (bool) $inheritEnv;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether environment variables will be inherited or not.
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @deprecated since version 3.3, to be removed in 4.0. Environment variables will always be inherited.
|
||||
*/
|
||||
public function areEnvironmentVariablesInherited()
|
||||
{
|
||||
@trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0. Environment variables will always be inherited.', __METHOD__), E_USER_DEPRECATED);
|
||||
|
||||
return $this->inheritEnv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a check between the timeout definition and the time the process started.
|
||||
*
|
||||
@@ -1342,6 +1161,20 @@ class Process implements \IteratorAggregate
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether TTY is supported on the current operating system.
|
||||
*/
|
||||
public static function isTtySupported(): bool
|
||||
{
|
||||
static $isTtySupported;
|
||||
|
||||
if (null === $isTtySupported) {
|
||||
$isTtySupported = (bool) @proc_open('echo 1 >/dev/null', array(array('file', '/dev/tty', 'r'), array('file', '/dev/tty', 'w'), array('file', '/dev/tty', 'w')), $pipes);
|
||||
}
|
||||
|
||||
return $isTtySupported;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether PTY is supported on the current operating system.
|
||||
*
|
||||
@@ -1364,10 +1197,8 @@ class Process implements \IteratorAggregate
|
||||
|
||||
/**
|
||||
* Creates the descriptors needed by the proc_open.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getDescriptors()
|
||||
private function getDescriptors(): array
|
||||
{
|
||||
if ($this->input instanceof \Iterator) {
|
||||
$this->input->rewind();
|
||||
@@ -1432,7 +1263,7 @@ class Process implements \IteratorAggregate
|
||||
|
||||
$this->readPipes($running && $blocking, '\\' !== \DIRECTORY_SEPARATOR || !$running);
|
||||
|
||||
if ($this->fallbackStatus && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
|
||||
if ($this->fallbackStatus && $this->isSigchildEnabled()) {
|
||||
$this->processInformation = $this->fallbackStatus + $this->processInformation;
|
||||
}
|
||||
|
||||
@@ -1452,7 +1283,7 @@ class Process implements \IteratorAggregate
|
||||
return self::$sigchild;
|
||||
}
|
||||
|
||||
if (!\function_exists('phpinfo') || \defined('HHVM_VERSION')) {
|
||||
if (!\function_exists('phpinfo')) {
|
||||
return self::$sigchild = false;
|
||||
}
|
||||
|
||||
@@ -1470,7 +1301,7 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* @throws LogicException in case output has been disabled or process is not started
|
||||
*/
|
||||
private function readPipesForOutput($caller, $blocking = false)
|
||||
private function readPipesForOutput(string $caller, bool $blocking = false)
|
||||
{
|
||||
if ($this->outputDisabled) {
|
||||
throw new LogicException('Output has been disabled.');
|
||||
@@ -1484,13 +1315,9 @@ class Process implements \IteratorAggregate
|
||||
/**
|
||||
* Validates and returns the filtered timeout.
|
||||
*
|
||||
* @param int|float|null $timeout
|
||||
*
|
||||
* @return float|null
|
||||
*
|
||||
* @throws InvalidArgumentException if the given timeout is a negative number
|
||||
*/
|
||||
private function validateTimeout($timeout)
|
||||
private function validateTimeout(?float $timeout): ?float
|
||||
{
|
||||
$timeout = (float) $timeout;
|
||||
|
||||
@@ -1509,7 +1336,7 @@ class Process implements \IteratorAggregate
|
||||
* @param bool $blocking Whether to use blocking calls or not
|
||||
* @param bool $close Whether to close file handles or not
|
||||
*/
|
||||
private function readPipes($blocking, $close)
|
||||
private function readPipes(bool $blocking, bool $close)
|
||||
{
|
||||
$result = $this->processPipes->readAndWrite($blocking, $close);
|
||||
|
||||
@@ -1528,7 +1355,7 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* @return int The exitcode
|
||||
*/
|
||||
private function close()
|
||||
private function close(): int
|
||||
{
|
||||
$this->processPipes->close();
|
||||
if (\is_resource($this->process)) {
|
||||
@@ -1541,7 +1368,7 @@ class Process implements \IteratorAggregate
|
||||
if ($this->processInformation['signaled'] && 0 < $this->processInformation['termsig']) {
|
||||
// if process has been signaled, no exitcode but a valid termsig, apply Unix convention
|
||||
$this->exitcode = 128 + $this->processInformation['termsig'];
|
||||
} elseif ($this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
|
||||
} elseif ($this->isSigchildEnabled()) {
|
||||
$this->processInformation['signaled'] = true;
|
||||
$this->processInformation['termsig'] = -1;
|
||||
}
|
||||
@@ -1586,7 +1413,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
|
||||
*/
|
||||
private function doSignal($signal, $throwException)
|
||||
private function doSignal(int $signal, bool $throwException): bool
|
||||
{
|
||||
if (null === $pid = $this->getPid()) {
|
||||
if ($throwException) {
|
||||
@@ -1606,7 +1433,7 @@ class Process implements \IteratorAggregate
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!$this->enhanceSigchildCompatibility || !$this->isSigchildEnabled()) {
|
||||
if (!$this->isSigchildEnabled()) {
|
||||
$ok = @proc_terminate($this->process, $signal);
|
||||
} elseif (\function_exists('posix_kill')) {
|
||||
$ok = @posix_kill($pid, $signal);
|
||||
@@ -1622,7 +1449,7 @@ class Process implements \IteratorAggregate
|
||||
}
|
||||
}
|
||||
|
||||
$this->latestSignal = (int) $signal;
|
||||
$this->latestSignal = $signal;
|
||||
$this->fallbackStatus['signaled'] = true;
|
||||
$this->fallbackStatus['exitcode'] = -1;
|
||||
$this->fallbackStatus['termsig'] = $this->latestSignal;
|
||||
@@ -1630,7 +1457,7 @@ class Process implements \IteratorAggregate
|
||||
return true;
|
||||
}
|
||||
|
||||
private function prepareWindowsCommandLine($cmd, array &$env)
|
||||
private function prepareWindowsCommandLine(string $cmd, array &$env)
|
||||
{
|
||||
$uid = uniqid('', true);
|
||||
$varCount = 0;
|
||||
@@ -1679,11 +1506,9 @@ class Process implements \IteratorAggregate
|
||||
/**
|
||||
* Ensures the process is running or terminated, throws a LogicException if the process has a not started.
|
||||
*
|
||||
* @param string $functionName The function name that was called
|
||||
*
|
||||
* @throws LogicException if the process has not run
|
||||
*/
|
||||
private function requireProcessIsStarted($functionName)
|
||||
private function requireProcessIsStarted(string $functionName)
|
||||
{
|
||||
if (!$this->isStarted()) {
|
||||
throw new LogicException(sprintf('Process must be started before calling %s.', $functionName));
|
||||
@@ -1693,11 +1518,9 @@ class Process implements \IteratorAggregate
|
||||
/**
|
||||
* Ensures the process is terminated, throws a LogicException if the process has a status different than `terminated`.
|
||||
*
|
||||
* @param string $functionName The function name that was called
|
||||
*
|
||||
* @throws LogicException if the process is not yet terminated
|
||||
*/
|
||||
private function requireProcessIsTerminated($functionName)
|
||||
private function requireProcessIsTerminated(string $functionName)
|
||||
{
|
||||
if (!$this->isTerminated()) {
|
||||
throw new LogicException(sprintf('Process must be terminated before calling %s.', $functionName));
|
||||
@@ -1706,12 +1529,8 @@ class Process implements \IteratorAggregate
|
||||
|
||||
/**
|
||||
* Escapes a string to be used as a shell argument.
|
||||
*
|
||||
* @param string $argument The argument that will be escaped
|
||||
*
|
||||
* @return string The escaped argument
|
||||
*/
|
||||
private function escapeArgument($argument)
|
||||
private function escapeArgument(string $argument): string
|
||||
{
|
||||
if ('\\' !== \DIRECTORY_SEPARATOR) {
|
||||
return "'".str_replace("'", "'\\''", $argument)."'";
|
||||
|
Reference in New Issue
Block a user