Refactored namespace for Symfony/process

This commit is contained in:
Netkas 2022-08-11 14:19:34 -04:00
parent 932520783b
commit 2e11ee89ea
23 changed files with 115 additions and 190 deletions

View file

@ -3,7 +3,7 @@ autoload:
make src/ncc/ThirdParty/defuse/php-encryption/autoload_spl.php
make src/ncc/ThirdParty/Symfony/polyfill-ctype/autoload_spl.php
make src/ncc/ThirdParty/Symfony/polyfill-mbstring/autoload_spl.php
make src/ncc/ThirdParty/Symfony/Process/autoload_spl.php
make src/ncc/ThirdParty/Symfony/process/autoload_spl.php
make src/ncc/ThirdParty/Symfony/uid/autoload_spl.php
make src/ncc/autoload_spl.php
cp src/autoload/autoload.php src/ncc/autoload.php
@ -20,9 +20,9 @@ src/ncc/ThirdParty/Symfony/polyfill-mbstring/autoload_spl.php:
phpab --output src/ncc/ThirdParty/Symfony/polyfill-mbstring/autoload_spl.php \
src/ncc/ThirdParty/Symfony/polyfill-mbstring
src/ncc/ThirdParty/Symfony/Process/autoload_spl.php:
phpab --output src/ncc/ThirdParty/Symfony/Process/autoload_spl.php \
src/ncc/ThirdParty/Symfony/Process
src/ncc/ThirdParty/Symfony/process/autoload_spl.php:
phpab --output src/ncc/ThirdParty/Symfony/process/autoload_spl.php \
src/ncc/ThirdParty/Symfony/process
src/ncc/ThirdParty/Symfony/uid/autoload_spl.php:
phpab --output src/ncc/ThirdParty/Symfony/uid/autoload_spl.php \
@ -60,5 +60,5 @@ clean:
rm -f src/ncc/ThirdParty/defuse/php-encryption/autoload_spl.php
rm -f src/ncc/ThirdParty/Symfony/polyfill-ctype/autoload_spl.php
rm -f src/ncc/ThirdParty/Symfony/polyfill-mbstring/autoload_spl.php
rm -f src/ncc/ThirdParty/Symfony/Process/autoload_spl.php
rm -f src/ncc/ThirdParty/Symfony/process/autoload_spl.php
rm -f src/ncc/ThirdParty/Symfony/uid/autoload_spl.php

View file

@ -1 +0,0 @@
6.0.8

View file

@ -57,7 +57,7 @@ CHANGELOG
* support for passing `proc_open()` options has been removed
* removed the `ProcessBuilder` class, use the `Process` class instead
* removed the `getEnhanceWindowsCompatibility()` and `setEnhanceWindowsCompatibility()` methods of the `Process` class
* passing a not existing working directory to the constructor of the `ncc\Symfony\Component\Process\Process` class is not
* passing a not existing working directory to the constructor of the `Symfony\Component\Process\Process` class is not
supported anymore
3.4.0

View file

@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
namespace ncc\Symfony\Component\Process\Exception;
namespace ncc\ThirdParty\Symfony\process\Exception;
/**
* Marker Interface for the Process Component.

View file

@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
namespace ncc\Symfony\Component\Process\Exception;
namespace ncc\ThirdParty\Symfony\process\Exception;
/**
* InvalidArgumentException for the Process Component.

View file

@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
namespace ncc\Symfony\Component\Process\Exception;
namespace ncc\ThirdParty\Symfony\process\Exception;
/**
* LogicException for the Process Component.

View file

@ -9,9 +9,9 @@
* file that was distributed with this source code.
*/
namespace ncc\Symfony\Component\Process\Exception;
namespace ncc\ThirdParty\Symfony\process\Exception;
use ncc\Symfony\Component\Process\Process;
use ncc\ThirdParty\Symfony\process\process;
/**
* Exception for failed processes.

View file

@ -9,9 +9,9 @@
* file that was distributed with this source code.
*/
namespace ncc\Symfony\Component\Process\Exception;
namespace ncc\ThirdParty\Symfony\process\Exception;
use ncc\Symfony\Component\Process\Process;
use ncc\ThirdParty\Symfony\process\process;
/**
* Exception that is thrown when a process has been signaled.

View file

@ -9,9 +9,9 @@
* file that was distributed with this source code.
*/
namespace ncc\Symfony\Component\Process\Exception;
namespace ncc\ThirdParty\Symfony\process\Exception;
use ncc\Symfony\Component\Process\Process;
use ncc\ThirdParty\Symfony\process\process;
/**
* Exception that is thrown when a process times out.
@ -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)),
};
}
}

View file

@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
namespace ncc\Symfony\Component\Process\Exception;
namespace ncc\ThirdParty\Symfony\process\Exception;
/**
* RuntimeException for the Process Component.

View file

@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
namespace ncc\Symfony\Component\Process;
namespace ncc\ThirdParty\Symfony\process;
/**
* Generic executable finder.
@ -43,13 +43,11 @@ 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);
if (\ini_get('open_basedir')) {
$searchPath = array_merge(explode(\PATH_SEPARATOR, \ini_get('open_basedir')), $extraDirs);
$dirs = [];
foreach ($searchPath as $path) {
// Silencing against https://bugs.php.net/69240

View file

@ -9,9 +9,9 @@
* file that was distributed with this source code.
*/
namespace ncc\Symfony\Component\Process;
namespace ncc\ThirdParty\Symfony\process;
use ncc\Symfony\Component\Process\Exception\RuntimeException;
use ncc\ThirdParty\Symfony\process\Exception\RuntimeException;
/**
* Provides a way to continuously write to the input of a Process until the InputStream is closed.
@ -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;

View file

@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
namespace ncc\Symfony\Component\Process;
namespace ncc\ThirdParty\Symfony\process;
/**
* An executable finder specifically designed for the PHP executable.
@ -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) {

View file

@ -9,10 +9,10 @@
* file that was distributed with this source code.
*/
namespace ncc\Symfony\Component\Process;
namespace ncc\ThirdParty\Symfony\process;
use ncc\Symfony\Component\Process\Exception\LogicException;
use ncc\Symfony\Component\Process\Exception\RuntimeException;
use ncc\ThirdParty\Symfony\process\Exception\LogicException;
use ncc\ThirdParty\Symfony\process\Exception\RuntimeException;
/**
* PhpProcess runs a PHP script in an independent process.
@ -53,7 +53,7 @@ class PhpProcess extends Process
/**
* {@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));
}

View file

@ -9,9 +9,9 @@
* file that was distributed with this source code.
*/
namespace ncc\Symfony\Component\Process\Pipes;
namespace ncc\ThirdParty\Symfony\process\Pipes;
use ncc\Symfony\Component\Process\Exception\InvalidArgumentException;
use ncc\ThirdParty\Symfony\process\Exception\InvalidArgumentException;
/**
* @author Romain Neutron <imprec@gmail.com>
@ -20,7 +20,7 @@ use ncc\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;
@ -104,7 +104,7 @@ abstract class AbstractPipes implements PipesInterface
stream_set_blocking($input, 0);
} elseif (!isset($this->inputBuffer[0])) {
if (!\is_string($input)) {
if (!is_scalar($input)) {
if (!\is_scalar($input)) {
throw new InvalidArgumentException(sprintf('"%s" yielded a value of type "%s", but only scalars and stream resources are supported.', get_debug_type($this->input), get_debug_type($input)));
}
$input = (string) $input;

View file

@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
namespace ncc\Symfony\Component\Process\Pipes;
namespace ncc\ThirdParty\Symfony\process\Pipes;
/**
* PipesInterface manages descriptors and pipes for the use of proc_open.

View file

@ -9,9 +9,9 @@
* file that was distributed with this source code.
*/
namespace ncc\Symfony\Component\Process\Pipes;
namespace ncc\ThirdParty\Symfony\process\Pipes;
use ncc\Symfony\Component\Process\Process;
use ncc\ThirdParty\Symfony\process\Process;
/**
* UnixPipes implementation uses unix pipes as handles.
@ -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;
@ -109,7 +109,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

View file

@ -9,10 +9,10 @@
* file that was distributed with this source code.
*/
namespace ncc\Symfony\Component\Process\Pipes;
namespace ncc\ThirdParty\Symfony\process\Pipes;
use ncc\Symfony\Component\Process\Exception\RuntimeException;
use ncc\Symfony\Component\Process\Process;
use ncc\ThirdParty\Symfony\process\Exception\RuntimeException;
use ncc\ThirdParty\Symfony\process\Process;
/**
* WindowsPipes implementation uses temporary files as handles.
@ -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;

View file

@ -9,17 +9,17 @@
* file that was distributed with this source code.
*/
namespace ncc\Symfony\Component\Process;
namespace ncc\ThirdParty\Symfony\process;
use ncc\Symfony\Component\Process\Exception\InvalidArgumentException;
use ncc\Symfony\Component\Process\Exception\LogicException;
use ncc\Symfony\Component\Process\Exception\ProcessFailedException;
use ncc\Symfony\Component\Process\Exception\ProcessSignaledException;
use ncc\Symfony\Component\Process\Exception\ProcessTimedOutException;
use ncc\Symfony\Component\Process\Exception\RuntimeException;
use ncc\Symfony\Component\Process\Pipes\PipesInterface;
use ncc\Symfony\Component\Process\Pipes\UnixPipes;
use ncc\Symfony\Component\Process\Pipes\WindowsPipes;
use ncc\ThirdParty\Symfony\process\Exception\InvalidArgumentException;
use ncc\ThirdParty\Symfony\process\Exception\LogicException;
use ncc\ThirdParty\Symfony\process\Exception\ProcessFailedException;
use ncc\ThirdParty\Symfony\process\Exception\ProcessSignaledException;
use ncc\ThirdParty\Symfony\process\Exception\ProcessTimedOutException;
use ncc\ThirdParty\Symfony\process\Exception\RuntimeException;
use ncc\ThirdParty\Symfony\process\Pipes\PipesInterface;
use ncc\ThirdParty\Symfony\process\Pipes\UnixPipes;
use ncc\ThirdParty\Symfony\process\Pipes\WindowsPipes;
/**
* Process is a thin wrapper around proc_* functions to easily
@ -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.');
@ -1265,10 +1213,8 @@ class Process implements \IteratorAggregate
/**
* 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 +1253,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 +1302,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;

View file

@ -9,9 +9,9 @@
* file that was distributed with this source code.
*/
namespace ncc\Symfony\Component\Process;
namespace ncc\ThirdParty\Symfony\process;
use ncc\Symfony\Component\Process\Exception\InvalidArgumentException;
use ncc\ThirdParty\Symfony\process\Exception\InvalidArgumentException;
/**
* ProcessUtils is a bunch of utility methods.
@ -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)) {
@ -48,7 +46,7 @@ class ProcessUtils
if (\is_string($input)) {
return $input;
}
if (is_scalar($input)) {
if (\is_scalar($input)) {
return (string) $input;
}
if ($input instanceof Process) {

View file

@ -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

View file

@ -0,0 +1 @@
6.1.3