Aggiornato Composer
This commit is contained in:
42
vendor/symfony/process/Process.php
vendored
42
vendor/symfony/process/Process.php
vendored
@@ -80,6 +80,7 @@ class Process implements \IteratorAggregate
|
||||
private $processPipes;
|
||||
|
||||
private $latestSignal;
|
||||
private $cachedExitCode;
|
||||
|
||||
private static $sigchild;
|
||||
|
||||
@@ -140,7 +141,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, $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.');
|
||||
@@ -189,7 +190,7 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* @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, $input = null, ?float $timeout = 60)
|
||||
{
|
||||
$process = new static([], $cwd, $env, $input, $timeout);
|
||||
$process->commandline = $command;
|
||||
@@ -247,7 +248,7 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
public function run(callable $callback = null, array $env = []): int
|
||||
public function run(?callable $callback = null, array $env = []): int
|
||||
{
|
||||
$this->start($callback, $env);
|
||||
|
||||
@@ -266,7 +267,7 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
public function mustRun(callable $callback = null, array $env = []): self
|
||||
public function mustRun(?callable $callback = null, array $env = []): self
|
||||
{
|
||||
if (0 !== $this->run($callback, $env)) {
|
||||
throw new ProcessFailedException($this);
|
||||
@@ -294,7 +295,7 @@ 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 = [])
|
||||
public function start(?callable $callback = null, array $env = [])
|
||||
{
|
||||
if ($this->isRunning()) {
|
||||
throw new RuntimeException('Process is already running.');
|
||||
@@ -331,7 +332,7 @@ class Process implements \IteratorAggregate
|
||||
|
||||
// See https://unix.stackexchange.com/questions/71205/background-process-pipe-input
|
||||
$commandline = '{ ('.$commandline.') <&3 3<&- 3>/dev/null & } 3<&0;';
|
||||
$commandline .= 'pid=$!; echo $pid >&3; wait $pid; code=$?; echo $code >&3; exit $code';
|
||||
$commandline .= 'pid=$!; echo $pid >&3; wait $pid 2>/dev/null; code=$?; echo $code >&3; exit $code';
|
||||
|
||||
// Workaround for the bug, when PTS functionality is enabled.
|
||||
// @see : https://bugs.php.net/69442
|
||||
@@ -385,7 +386,7 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
public function restart(callable $callback = null, array $env = []): self
|
||||
public function restart(?callable $callback = null, array $env = []): self
|
||||
{
|
||||
if ($this->isRunning()) {
|
||||
throw new RuntimeException('Process is already running.');
|
||||
@@ -412,7 +413,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)
|
||||
{
|
||||
$this->requireProcessIsStarted(__FUNCTION__);
|
||||
|
||||
@@ -428,7 +429,7 @@ class Process implements \IteratorAggregate
|
||||
|
||||
do {
|
||||
$this->checkTimeout();
|
||||
$running = '\\' === \DIRECTORY_SEPARATOR ? $this->isRunning() : $this->processPipes->areOpen();
|
||||
$running = $this->isRunning() && ('\\' === \DIRECTORY_SEPARATOR || $this->processPipes->areOpen());
|
||||
$this->readPipes($running, '\\' !== \DIRECTORY_SEPARATOR || !$running);
|
||||
} while ($running);
|
||||
|
||||
@@ -617,10 +618,10 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* @param int $flags A bit field of Process::ITER_* flags
|
||||
*
|
||||
* @return \Generator<string, string>
|
||||
*
|
||||
* @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)
|
||||
@@ -910,11 +911,11 @@ class Process implements \IteratorAggregate
|
||||
* Stops the process.
|
||||
*
|
||||
* @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)
|
||||
* @param int|null $signal A POSIX signal to send in case the process has not stop at timeout, default is SIGKILL (9)
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
$timeoutMicro = microtime(true) + $timeout;
|
||||
if ($this->isRunning()) {
|
||||
@@ -1310,7 +1311,7 @@ class Process implements \IteratorAggregate
|
||||
*
|
||||
* @return \Closure
|
||||
*/
|
||||
protected function buildCallback(callable $callback = null)
|
||||
protected function buildCallback(?callable $callback = null)
|
||||
{
|
||||
if ($this->outputDisabled) {
|
||||
return function ($type, $data) use ($callback): bool {
|
||||
@@ -1345,6 +1346,19 @@ class Process implements \IteratorAggregate
|
||||
$this->processInformation = proc_get_status($this->process);
|
||||
$running = $this->processInformation['running'];
|
||||
|
||||
// In PHP < 8.3, "proc_get_status" only returns the correct exit status on the first call.
|
||||
// Subsequent calls return -1 as the process is discarded. This workaround caches the first
|
||||
// retrieved exit status for consistent results in later calls, mimicking PHP 8.3 behavior.
|
||||
if (\PHP_VERSION_ID < 80300) {
|
||||
if (!isset($this->cachedExitCode) && !$running && -1 !== $this->processInformation['exitcode']) {
|
||||
$this->cachedExitCode = $this->processInformation['exitcode'];
|
||||
}
|
||||
|
||||
if (isset($this->cachedExitCode) && !$running && -1 === $this->processInformation['exitcode']) {
|
||||
$this->processInformation['exitcode'] = $this->cachedExitCode;
|
||||
}
|
||||
}
|
||||
|
||||
$this->readPipes($running && $blocking, '\\' !== \DIRECTORY_SEPARATOR || !$running);
|
||||
|
||||
if ($this->fallbackStatus && $this->isSigchildEnabled()) {
|
||||
|
||||
Reference in New Issue
Block a user