package and depencies
This commit is contained in:
@@ -55,15 +55,10 @@ class ProcessTimedOutException extends RuntimeException
|
||||
|
||||
public function getExceededTimeout()
|
||||
{
|
||||
switch ($this->timeoutType) {
|
||||
case self::TYPE_GENERAL:
|
||||
return $this->process->getTimeout();
|
||||
|
||||
case self::TYPE_IDLE:
|
||||
return $this->process->getIdleTimeout();
|
||||
|
||||
default:
|
||||
throw new \LogicException(sprintf('Unknown timeout type "%d".', $this->timeoutType));
|
||||
}
|
||||
return match ($this->timeoutType) {
|
||||
self::TYPE_GENERAL => $this->process->getTimeout(),
|
||||
self::TYPE_IDLE => $this->process->getIdleTimeout(),
|
||||
default => throw new \LogicException(sprintf('Unknown timeout type "%d".', $this->timeoutType)),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
4
vendor/symfony/process/ExecutableFinder.php
vendored
4
vendor/symfony/process/ExecutableFinder.php
vendored
@@ -43,10 +43,8 @@ class ExecutableFinder
|
||||
* @param string $name The executable name (without the extension)
|
||||
* @param string|null $default The default to return if no executable is found
|
||||
* @param array $extraDirs Additional dirs to check into
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function find(string $name, string $default = null, array $extraDirs = [])
|
||||
public function find(string $name, string $default = null, array $extraDirs = []): ?string
|
||||
{
|
||||
if (\ini_get('open_basedir')) {
|
||||
$searchPath = array_merge(explode(\PATH_SEPARATOR, \ini_get('open_basedir')), $extraDirs);
|
||||
|
8
vendor/symfony/process/InputStream.php
vendored
8
vendor/symfony/process/InputStream.php
vendored
@@ -41,7 +41,7 @@ class InputStream implements \IteratorAggregate
|
||||
* @param resource|string|int|float|bool|\Traversable|null $input The input to append as scalar,
|
||||
* stream resource or \Traversable
|
||||
*/
|
||||
public function write($input)
|
||||
public function write(mixed $input)
|
||||
{
|
||||
if (null === $input) {
|
||||
return;
|
||||
@@ -68,11 +68,7 @@ class InputStream implements \IteratorAggregate
|
||||
return !$this->open;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Traversable<int, string>
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function getIterator()
|
||||
public function getIterator(): \Traversable
|
||||
{
|
||||
$this->open = true;
|
||||
|
||||
|
@@ -28,10 +28,8 @@ class PhpExecutableFinder
|
||||
|
||||
/**
|
||||
* Finds The PHP executable.
|
||||
*
|
||||
* @return string|false
|
||||
*/
|
||||
public function find(bool $includeArgs = true)
|
||||
public function find(bool $includeArgs = true): string|false
|
||||
{
|
||||
if ($php = getenv('PHP_BINARY')) {
|
||||
if (!is_executable($php)) {
|
||||
@@ -88,10 +86,8 @@ class PhpExecutableFinder
|
||||
|
||||
/**
|
||||
* Finds the PHP executable arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function findArguments()
|
||||
public function findArguments(): array
|
||||
{
|
||||
$arguments = [];
|
||||
if ('phpdbg' === \PHP_SAPI) {
|
||||
|
8
vendor/symfony/process/PhpProcess.php
vendored
8
vendor/symfony/process/PhpProcess.php
vendored
@@ -50,17 +50,11 @@ class PhpProcess extends Process
|
||||
parent::__construct($php, $cwd, $env, $script, $timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function fromShellCommandline(string $command, string $cwd = null, array $env = null, $input = null, ?float $timeout = 60)
|
||||
public static function fromShellCommandline(string $command, string $cwd = null, array $env = null, mixed $input = null, ?float $timeout = 60): static
|
||||
{
|
||||
throw new LogicException(sprintf('The "%s()" method cannot be called when using "%s".', __METHOD__, self::class));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function start(callable $callback = null, array $env = [])
|
||||
{
|
||||
if (null === $this->getCommandLine()) {
|
||||
|
@@ -20,7 +20,7 @@ use Symfony\Component\Process\Exception\InvalidArgumentException;
|
||||
*/
|
||||
abstract class AbstractPipes implements PipesInterface
|
||||
{
|
||||
public $pipes = [];
|
||||
public array $pipes = [];
|
||||
|
||||
private $inputBuffer = '';
|
||||
private $input;
|
||||
@@ -30,7 +30,7 @@ abstract class AbstractPipes implements PipesInterface
|
||||
/**
|
||||
* @param resource|string|int|float|bool|\Iterator|null $input
|
||||
*/
|
||||
public function __construct($input)
|
||||
public function __construct(mixed $input)
|
||||
{
|
||||
if (\is_resource($input) || $input instanceof \Iterator) {
|
||||
$this->input = $input;
|
||||
@@ -41,9 +41,6 @@ abstract class AbstractPipes implements PipesInterface
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function close()
|
||||
{
|
||||
foreach ($this->pipes as $pipe) {
|
||||
|
19
vendor/symfony/process/Pipes/UnixPipes.php
vendored
19
vendor/symfony/process/Pipes/UnixPipes.php
vendored
@@ -26,7 +26,7 @@ class UnixPipes extends AbstractPipes
|
||||
private $ptyMode;
|
||||
private $haveReadSupport;
|
||||
|
||||
public function __construct(?bool $ttyMode, bool $ptyMode, $input, bool $haveReadSupport)
|
||||
public function __construct(?bool $ttyMode, bool $ptyMode, mixed $input, bool $haveReadSupport)
|
||||
{
|
||||
$this->ttyMode = $ttyMode;
|
||||
$this->ptyMode = $ptyMode;
|
||||
@@ -50,9 +50,6 @@ class UnixPipes extends AbstractPipes
|
||||
$this->close();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDescriptors(): array
|
||||
{
|
||||
if (!$this->haveReadSupport) {
|
||||
@@ -88,17 +85,11 @@ class UnixPipes extends AbstractPipes
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFiles(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function readAndWrite(bool $blocking, bool $close = false): array
|
||||
{
|
||||
$this->unblock();
|
||||
@@ -109,7 +100,7 @@ class UnixPipes extends AbstractPipes
|
||||
unset($r[0]);
|
||||
|
||||
// let's have a look if something changed in streams
|
||||
set_error_handler([$this, 'handleError']);
|
||||
set_error_handler($this->handleError(...));
|
||||
if (($r || $w) && false === stream_select($r, $w, $e, 0, $blocking ? Process::TIMEOUT_PRECISION * 1E6 : 0)) {
|
||||
restore_error_handler();
|
||||
// if a system call has been interrupted, forget about it, let's try again
|
||||
@@ -145,17 +136,11 @@ class UnixPipes extends AbstractPipes
|
||||
return $read;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function haveReadSupport(): bool
|
||||
{
|
||||
return $this->haveReadSupport;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function areOpen(): bool
|
||||
{
|
||||
return (bool) $this->pipes;
|
||||
|
20
vendor/symfony/process/Pipes/WindowsPipes.php
vendored
20
vendor/symfony/process/Pipes/WindowsPipes.php
vendored
@@ -35,7 +35,7 @@ class WindowsPipes extends AbstractPipes
|
||||
];
|
||||
private $haveReadSupport;
|
||||
|
||||
public function __construct($input, bool $haveReadSupport)
|
||||
public function __construct(mixed $input, bool $haveReadSupport)
|
||||
{
|
||||
$this->haveReadSupport = $haveReadSupport;
|
||||
|
||||
@@ -103,9 +103,6 @@ class WindowsPipes extends AbstractPipes
|
||||
$this->close();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDescriptors(): array
|
||||
{
|
||||
if (!$this->haveReadSupport) {
|
||||
@@ -128,17 +125,11 @@ class WindowsPipes extends AbstractPipes
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFiles(): array
|
||||
{
|
||||
return $this->files;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function readAndWrite(bool $blocking, bool $close = false): array
|
||||
{
|
||||
$this->unblock();
|
||||
@@ -171,25 +162,16 @@ class WindowsPipes extends AbstractPipes
|
||||
return $read;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function haveReadSupport(): bool
|
||||
{
|
||||
return $this->haveReadSupport;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function areOpen(): bool
|
||||
{
|
||||
return $this->pipes && $this->fileHandles;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function close()
|
||||
{
|
||||
parent::close();
|
||||
|
162
vendor/symfony/process/Process.php
vendored
162
vendor/symfony/process/Process.php
vendored
@@ -140,7 +140,7 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* @throws LogicException When proc_open is not installed
|
||||
*/
|
||||
public function __construct(array $command, string $cwd = null, array $env = null, $input = null, ?float $timeout = 60)
|
||||
public function __construct(array $command, string $cwd = null, array $env = null, mixed $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.');
|
||||
@@ -185,11 +185,9 @@ class Process implements \IteratorAggregate
|
||||
* @param mixed $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 LogicException When proc_open is not installed
|
||||
*/
|
||||
public static function fromShellCommandline(string $command, string $cwd = null, array $env = null, $input = null, ?float $timeout = 60)
|
||||
public static function fromShellCommandline(string $command, string $cwd = null, array $env = null, mixed $input = null, ?float $timeout = 60): static
|
||||
{
|
||||
$process = new static([], $cwd, $env, $input, $timeout);
|
||||
$process->commandline = $command;
|
||||
@@ -197,10 +195,7 @@ class Process implements \IteratorAggregate
|
||||
return $process;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function __sleep()
|
||||
public function __sleep(): array
|
||||
{
|
||||
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
|
||||
}
|
||||
@@ -266,7 +261,7 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
public function mustRun(callable $callback = null, array $env = []): self
|
||||
public function mustRun(callable $callback = null, array $env = []): static
|
||||
{
|
||||
if (0 !== $this->run($callback, $env)) {
|
||||
throw new ProcessFailedException($this);
|
||||
@@ -313,7 +308,7 @@ class Process implements \IteratorAggregate
|
||||
$env += '\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($this->getDefaultEnv(), $env, 'strcasecmp') : $this->getDefaultEnv();
|
||||
|
||||
if (\is_array($commandline = $this->commandline)) {
|
||||
$commandline = implode(' ', array_map([$this, 'escapeArgument'], $commandline));
|
||||
$commandline = implode(' ', array_map($this->escapeArgument(...), $commandline));
|
||||
|
||||
if ('\\' !== \DIRECTORY_SEPARATOR) {
|
||||
// exec is mandatory to deal with sending a signal to the process
|
||||
@@ -376,8 +371,6 @@ class Process implements \IteratorAggregate
|
||||
* @param callable|null $callback A PHP callback to run whenever there is some
|
||||
* output available on STDOUT or STDERR
|
||||
*
|
||||
* @return static
|
||||
*
|
||||
* @throws RuntimeException When process can't be launched
|
||||
* @throws RuntimeException When process is already running
|
||||
*
|
||||
@@ -385,7 +378,7 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
public function restart(callable $callback = null, array $env = []): self
|
||||
public function restart(callable $callback = null, array $env = []): static
|
||||
{
|
||||
if ($this->isRunning()) {
|
||||
throw new RuntimeException('Process is already running.');
|
||||
@@ -412,7 +405,7 @@ class Process implements \IteratorAggregate
|
||||
* @throws ProcessSignaledException When process stopped after receiving signal
|
||||
* @throws LogicException When process is not yet started
|
||||
*/
|
||||
public function wait(callable $callback = null)
|
||||
public function wait(callable $callback = null): int
|
||||
{
|
||||
$this->requireProcessIsStarted(__FUNCTION__);
|
||||
|
||||
@@ -495,7 +488,7 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* @return int|null The process id if running, null otherwise
|
||||
*/
|
||||
public function getPid()
|
||||
public function getPid(): ?int
|
||||
{
|
||||
return $this->isRunning() ? $this->processInformation['pid'] : null;
|
||||
}
|
||||
@@ -511,7 +504,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(int $signal)
|
||||
public function signal(int $signal): static
|
||||
{
|
||||
$this->doSignal($signal, true);
|
||||
|
||||
@@ -526,7 +519,7 @@ class Process implements \IteratorAggregate
|
||||
* @throws RuntimeException In case the process is already running
|
||||
* @throws LogicException if an idle timeout is set
|
||||
*/
|
||||
public function disableOutput()
|
||||
public function disableOutput(): static
|
||||
{
|
||||
if ($this->isRunning()) {
|
||||
throw new RuntimeException('Disabling output while the process is running is not possible.');
|
||||
@@ -547,7 +540,7 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* @throws RuntimeException In case the process is already running
|
||||
*/
|
||||
public function enableOutput()
|
||||
public function enableOutput(): static
|
||||
{
|
||||
if ($this->isRunning()) {
|
||||
throw new RuntimeException('Enabling output while the process is running is not possible.');
|
||||
@@ -560,10 +553,8 @@ class Process implements \IteratorAggregate
|
||||
|
||||
/**
|
||||
* Returns true in case the output is disabled, false otherwise.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isOutputDisabled()
|
||||
public function isOutputDisabled(): bool
|
||||
{
|
||||
return $this->outputDisabled;
|
||||
}
|
||||
@@ -571,12 +562,10 @@ class Process implements \IteratorAggregate
|
||||
/**
|
||||
* Returns the current output of the process (STDOUT).
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws LogicException in case the output has been disabled
|
||||
* @throws LogicException In case the process is not started
|
||||
*/
|
||||
public function getOutput()
|
||||
public function getOutput(): string
|
||||
{
|
||||
$this->readPipesForOutput(__FUNCTION__);
|
||||
|
||||
@@ -593,12 +582,10 @@ class Process implements \IteratorAggregate
|
||||
* In comparison with the getOutput method which always return the whole
|
||||
* output, this one returns the new output since the last call.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws LogicException in case the output has been disabled
|
||||
* @throws LogicException In case the process is not started
|
||||
*/
|
||||
public function getIncrementalOutput()
|
||||
public function getIncrementalOutput(): string
|
||||
{
|
||||
$this->readPipesForOutput(__FUNCTION__);
|
||||
|
||||
@@ -619,11 +606,8 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* @throws LogicException in case the output has been disabled
|
||||
* @throws LogicException In case the process is not started
|
||||
*
|
||||
* @return \Generator<string, string>
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function getIterator(int $flags = 0)
|
||||
public function getIterator(int $flags = 0): \Generator
|
||||
{
|
||||
$this->readPipesForOutput(__FUNCTION__, false);
|
||||
|
||||
@@ -675,7 +659,7 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function clearOutput()
|
||||
public function clearOutput(): static
|
||||
{
|
||||
ftruncate($this->stdout, 0);
|
||||
fseek($this->stdout, 0);
|
||||
@@ -687,12 +671,10 @@ class Process implements \IteratorAggregate
|
||||
/**
|
||||
* Returns the current error output of the process (STDERR).
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws LogicException in case the output has been disabled
|
||||
* @throws LogicException In case the process is not started
|
||||
*/
|
||||
public function getErrorOutput()
|
||||
public function getErrorOutput(): string
|
||||
{
|
||||
$this->readPipesForOutput(__FUNCTION__);
|
||||
|
||||
@@ -710,12 +692,10 @@ class Process implements \IteratorAggregate
|
||||
* whole error output, this one returns the new error output since the last
|
||||
* call.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws LogicException in case the output has been disabled
|
||||
* @throws LogicException In case the process is not started
|
||||
*/
|
||||
public function getIncrementalErrorOutput()
|
||||
public function getIncrementalErrorOutput(): string
|
||||
{
|
||||
$this->readPipesForOutput(__FUNCTION__);
|
||||
|
||||
@@ -734,7 +714,7 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function clearErrorOutput()
|
||||
public function clearErrorOutput(): static
|
||||
{
|
||||
ftruncate($this->stderr, 0);
|
||||
fseek($this->stderr, 0);
|
||||
@@ -748,7 +728,7 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* @return int|null The exit status code, null if the Process is not terminated
|
||||
*/
|
||||
public function getExitCode()
|
||||
public function getExitCode(): ?int
|
||||
{
|
||||
$this->updateStatus(false);
|
||||
|
||||
@@ -766,7 +746,7 @@ class Process implements \IteratorAggregate
|
||||
* @see http://tldp.org/LDP/abs/html/exitcodes.html
|
||||
* @see http://en.wikipedia.org/wiki/Unix_signal
|
||||
*/
|
||||
public function getExitCodeText()
|
||||
public function getExitCodeText(): ?string
|
||||
{
|
||||
if (null === $exitcode = $this->getExitCode()) {
|
||||
return null;
|
||||
@@ -777,10 +757,8 @@ class Process implements \IteratorAggregate
|
||||
|
||||
/**
|
||||
* Checks if the process ended successfully.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSuccessful()
|
||||
public function isSuccessful(): bool
|
||||
{
|
||||
return 0 === $this->getExitCode();
|
||||
}
|
||||
@@ -790,11 +768,9 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* It always returns false on Windows.
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws LogicException In case the process is not terminated
|
||||
*/
|
||||
public function hasBeenSignaled()
|
||||
public function hasBeenSignaled(): bool
|
||||
{
|
||||
$this->requireProcessIsTerminated(__FUNCTION__);
|
||||
|
||||
@@ -806,12 +782,10 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* It is only meaningful if hasBeenSignaled() returns true.
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @throws RuntimeException In case --enable-sigchild is activated
|
||||
* @throws LogicException In case the process is not terminated
|
||||
*/
|
||||
public function getTermSignal()
|
||||
public function getTermSignal(): int
|
||||
{
|
||||
$this->requireProcessIsTerminated(__FUNCTION__);
|
||||
|
||||
@@ -827,11 +801,9 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* It always returns false on Windows.
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws LogicException In case the process is not terminated
|
||||
*/
|
||||
public function hasBeenStopped()
|
||||
public function hasBeenStopped(): bool
|
||||
{
|
||||
$this->requireProcessIsTerminated(__FUNCTION__);
|
||||
|
||||
@@ -843,11 +815,9 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* It is only meaningful if hasBeenStopped() returns true.
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @throws LogicException In case the process is not terminated
|
||||
*/
|
||||
public function getStopSignal()
|
||||
public function getStopSignal(): int
|
||||
{
|
||||
$this->requireProcessIsTerminated(__FUNCTION__);
|
||||
|
||||
@@ -856,10 +826,8 @@ class Process implements \IteratorAggregate
|
||||
|
||||
/**
|
||||
* Checks if the process is currently running.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isRunning()
|
||||
public function isRunning(): bool
|
||||
{
|
||||
if (self::STATUS_STARTED !== $this->status) {
|
||||
return false;
|
||||
@@ -872,20 +840,16 @@ class Process implements \IteratorAggregate
|
||||
|
||||
/**
|
||||
* Checks if the process has been started with no regard to the current state.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isStarted()
|
||||
public function isStarted(): bool
|
||||
{
|
||||
return self::STATUS_READY != $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the process is terminated.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isTerminated()
|
||||
public function isTerminated(): bool
|
||||
{
|
||||
$this->updateStatus(false);
|
||||
|
||||
@@ -896,10 +860,8 @@ class Process implements \IteratorAggregate
|
||||
* Gets the process status.
|
||||
*
|
||||
* The status is one of: ready, started, terminated.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStatus()
|
||||
public function getStatus(): string
|
||||
{
|
||||
$this->updateStatus(false);
|
||||
|
||||
@@ -914,7 +876,7 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* @return int|null The exit-code of the process or null if it's not running
|
||||
*/
|
||||
public function stop(float $timeout = 10, int $signal = null)
|
||||
public function stop(float $timeout = 10, int $signal = null): ?int
|
||||
{
|
||||
$timeoutMicro = microtime(true) + $timeout;
|
||||
if ($this->isRunning()) {
|
||||
@@ -981,30 +943,24 @@ class Process implements \IteratorAggregate
|
||||
|
||||
/**
|
||||
* Gets the command line to be executed.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCommandLine()
|
||||
public function getCommandLine(): string
|
||||
{
|
||||
return \is_array($this->commandline) ? implode(' ', array_map([$this, 'escapeArgument'], $this->commandline)) : $this->commandline;
|
||||
return \is_array($this->commandline) ? implode(' ', array_map($this->escapeArgument(...), $this->commandline)) : $this->commandline;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the process timeout in seconds (max. runtime).
|
||||
*
|
||||
* @return float|null
|
||||
*/
|
||||
public function getTimeout()
|
||||
public function getTimeout(): ?float
|
||||
{
|
||||
return $this->timeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the process idle timeout in seconds (max. time since last output).
|
||||
*
|
||||
* @return float|null
|
||||
*/
|
||||
public function getIdleTimeout()
|
||||
public function getIdleTimeout(): ?float
|
||||
{
|
||||
return $this->idleTimeout;
|
||||
}
|
||||
@@ -1018,7 +974,7 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* @throws InvalidArgumentException if the timeout is negative
|
||||
*/
|
||||
public function setTimeout(?float $timeout)
|
||||
public function setTimeout(?float $timeout): static
|
||||
{
|
||||
$this->timeout = $this->validateTimeout($timeout);
|
||||
|
||||
@@ -1035,7 +991,7 @@ class Process implements \IteratorAggregate
|
||||
* @throws LogicException if the output is disabled
|
||||
* @throws InvalidArgumentException if the timeout is negative
|
||||
*/
|
||||
public function setIdleTimeout(?float $timeout)
|
||||
public function setIdleTimeout(?float $timeout): static
|
||||
{
|
||||
if (null !== $timeout && $this->outputDisabled) {
|
||||
throw new LogicException('Idle timeout cannot be set while the output is disabled.');
|
||||
@@ -1053,7 +1009,7 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* @throws RuntimeException In case the TTY mode is not supported
|
||||
*/
|
||||
public function setTty(bool $tty)
|
||||
public function setTty(bool $tty): static
|
||||
{
|
||||
if ('\\' === \DIRECTORY_SEPARATOR && $tty) {
|
||||
throw new RuntimeException('TTY mode is not supported on Windows platform.');
|
||||
@@ -1070,10 +1026,8 @@ class Process implements \IteratorAggregate
|
||||
|
||||
/**
|
||||
* Checks if the TTY mode is enabled.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isTty()
|
||||
public function isTty(): bool
|
||||
{
|
||||
return $this->tty;
|
||||
}
|
||||
@@ -1083,7 +1037,7 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPty(bool $bool)
|
||||
public function setPty(bool $bool): static
|
||||
{
|
||||
$this->pty = $bool;
|
||||
|
||||
@@ -1092,20 +1046,16 @@ class Process implements \IteratorAggregate
|
||||
|
||||
/**
|
||||
* Returns PTY state.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isPty()
|
||||
public function isPty(): bool
|
||||
{
|
||||
return $this->pty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the working directory.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getWorkingDirectory()
|
||||
public function getWorkingDirectory(): ?string
|
||||
{
|
||||
if (null === $this->cwd) {
|
||||
// getcwd() will return false if any one of the parent directories does not have
|
||||
@@ -1121,7 +1071,7 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setWorkingDirectory(string $cwd)
|
||||
public function setWorkingDirectory(string $cwd): static
|
||||
{
|
||||
$this->cwd = $cwd;
|
||||
|
||||
@@ -1130,10 +1080,8 @@ class Process implements \IteratorAggregate
|
||||
|
||||
/**
|
||||
* Gets the environment variables.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getEnv()
|
||||
public function getEnv(): array
|
||||
{
|
||||
return $this->env;
|
||||
}
|
||||
@@ -1145,7 +1093,7 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setEnv(array $env)
|
||||
public function setEnv(array $env): static
|
||||
{
|
||||
$this->env = $env;
|
||||
|
||||
@@ -1173,7 +1121,7 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* @throws LogicException In case the process is running
|
||||
*/
|
||||
public function setInput($input)
|
||||
public function setInput(mixed $input): static
|
||||
{
|
||||
if ($this->isRunning()) {
|
||||
throw new LogicException('Input cannot be set while the process is running.');
|
||||
@@ -1256,19 +1204,13 @@ class Process implements \IteratorAggregate
|
||||
{
|
||||
static $isTtySupported;
|
||||
|
||||
if (null === $isTtySupported) {
|
||||
$isTtySupported = (bool) @proc_open('echo 1 >/dev/null', [['file', '/dev/tty', 'r'], ['file', '/dev/tty', 'w'], ['file', '/dev/tty', 'w']], $pipes);
|
||||
}
|
||||
|
||||
return $isTtySupported;
|
||||
return $isTtySupported ??= ('/' === \DIRECTORY_SEPARATOR && stream_isatty(\STDOUT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether PTY is supported on the current operating system.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isPtySupported()
|
||||
public static function isPtySupported(): bool
|
||||
{
|
||||
static $result;
|
||||
|
||||
@@ -1307,10 +1249,8 @@ class Process implements \IteratorAggregate
|
||||
* the user callback (if present) with the received output.
|
||||
*
|
||||
* @param callable|null $callback The user defined PHP callback
|
||||
*
|
||||
* @return \Closure
|
||||
*/
|
||||
protected function buildCallback(callable $callback = null)
|
||||
protected function buildCallback(callable $callback = null): \Closure
|
||||
{
|
||||
if ($this->outputDisabled) {
|
||||
return function ($type, $data) use ($callback): bool {
|
||||
@@ -1358,10 +1298,8 @@ class Process implements \IteratorAggregate
|
||||
|
||||
/**
|
||||
* Returns whether PHP has been compiled with the '--enable-sigchild' option or not.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function isSigchildEnabled()
|
||||
protected function isSigchildEnabled(): bool
|
||||
{
|
||||
if (null !== self::$sigchild) {
|
||||
return self::$sigchild;
|
||||
|
4
vendor/symfony/process/ProcessUtils.php
vendored
4
vendor/symfony/process/ProcessUtils.php
vendored
@@ -35,11 +35,9 @@ class ProcessUtils
|
||||
* @param string $caller The name of method call that validates the input
|
||||
* @param mixed $input The input to validate
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws InvalidArgumentException In case the input is not valid
|
||||
*/
|
||||
public static function validateInput(string $caller, $input)
|
||||
public static function validateInput(string $caller, mixed $input): mixed
|
||||
{
|
||||
if (null !== $input) {
|
||||
if (\is_resource($input)) {
|
||||
|
2
vendor/symfony/process/README.md
vendored
2
vendor/symfony/process/README.md
vendored
@@ -6,7 +6,7 @@ The Process component executes commands in sub-processes.
|
||||
Sponsor
|
||||
-------
|
||||
|
||||
The Process component for Symfony 5.4/6.0 is [backed][1] by [SensioLabs][2].
|
||||
The Process component for Symfony 6.1 is [backed][1] by [SensioLabs][2].
|
||||
|
||||
As the creator of Symfony, SensioLabs supports companies using Symfony, with an
|
||||
offering encompassing consultancy, expertise, services, training, and technical
|
||||
|
3
vendor/symfony/process/composer.json
vendored
3
vendor/symfony/process/composer.json
vendored
@@ -16,8 +16,7 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.2.5",
|
||||
"symfony/polyfill-php80": "^1.16"
|
||||
"php": ">=8.1"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Symfony\\Component\\Process\\": "" },
|
||||
|
Reference in New Issue
Block a user