Laravel version update
Laravel version update
This commit is contained in:
69
vendor/symfony/process/Pipes/AbstractPipes.php
vendored
69
vendor/symfony/process/Pipes/AbstractPipes.php
vendored
@@ -11,6 +11,8 @@
|
||||
|
||||
namespace Symfony\Component\Process\Pipes;
|
||||
|
||||
use Symfony\Component\Process\Exception\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* @author Romain Neutron <imprec@gmail.com>
|
||||
*
|
||||
@@ -18,21 +20,21 @@ namespace Symfony\Component\Process\Pipes;
|
||||
*/
|
||||
abstract class AbstractPipes implements PipesInterface
|
||||
{
|
||||
/** @var array */
|
||||
public $pipes = array();
|
||||
|
||||
/** @var string */
|
||||
private $inputBuffer = '';
|
||||
/** @var resource|null */
|
||||
private $input;
|
||||
/** @var bool */
|
||||
private $blocked = true;
|
||||
private $lastError;
|
||||
|
||||
/**
|
||||
* @param resource|string|int|float|bool|\Iterator|null $input
|
||||
*/
|
||||
public function __construct($input)
|
||||
{
|
||||
if (is_resource($input)) {
|
||||
if (\is_resource($input) || $input instanceof \Iterator) {
|
||||
$this->input = $input;
|
||||
} elseif (is_string($input)) {
|
||||
} elseif (\is_string($input)) {
|
||||
$this->inputBuffer = $input;
|
||||
} else {
|
||||
$this->inputBuffer = (string) $input;
|
||||
@@ -57,10 +59,11 @@ abstract class AbstractPipes implements PipesInterface
|
||||
*/
|
||||
protected function hasSystemCallBeenInterrupted()
|
||||
{
|
||||
$lastError = error_get_last();
|
||||
$lastError = $this->lastError;
|
||||
$this->lastError = null;
|
||||
|
||||
// stream_select returns false when the `select` system call is interrupted by an incoming signal
|
||||
return isset($lastError['message']) && false !== stripos($lastError['message'], 'interrupted system call');
|
||||
return null !== $lastError && false !== stripos($lastError, 'interrupted system call');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,7 +78,7 @@ abstract class AbstractPipes implements PipesInterface
|
||||
foreach ($this->pipes as $pipe) {
|
||||
stream_set_blocking($pipe, 0);
|
||||
}
|
||||
if (null !== $this->input) {
|
||||
if (\is_resource($this->input)) {
|
||||
stream_set_blocking($this->input, 0);
|
||||
}
|
||||
|
||||
@@ -84,6 +87,8 @@ abstract class AbstractPipes implements PipesInterface
|
||||
|
||||
/**
|
||||
* Writes input to stdin.
|
||||
*
|
||||
* @throws InvalidArgumentException When an input iterator yields a non supported value
|
||||
*/
|
||||
protected function write()
|
||||
{
|
||||
@@ -91,11 +96,32 @@ abstract class AbstractPipes implements PipesInterface
|
||||
return;
|
||||
}
|
||||
$input = $this->input;
|
||||
|
||||
if ($input instanceof \Iterator) {
|
||||
if (!$input->valid()) {
|
||||
$input = null;
|
||||
} elseif (\is_resource($input = $input->current())) {
|
||||
stream_set_blocking($input, 0);
|
||||
} elseif (!isset($this->inputBuffer[0])) {
|
||||
if (!\is_string($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_class($this->input), \gettype($input)));
|
||||
}
|
||||
$input = (string) $input;
|
||||
}
|
||||
$this->inputBuffer = $input;
|
||||
$this->input->next();
|
||||
$input = null;
|
||||
} else {
|
||||
$input = null;
|
||||
}
|
||||
}
|
||||
|
||||
$r = $e = array();
|
||||
$w = array($this->pipes[0]);
|
||||
|
||||
// let's have a look if something changed in streams
|
||||
if (false === $n = @stream_select($r, $w, $e, 0, 0)) {
|
||||
if (false === @stream_select($r, $w, $e, 0, 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -123,21 +149,30 @@ abstract class AbstractPipes implements PipesInterface
|
||||
}
|
||||
}
|
||||
if (feof($input)) {
|
||||
// no more data to read on input resource
|
||||
// use an empty buffer in the next reads
|
||||
$this->input = null;
|
||||
if ($this->input instanceof \Iterator) {
|
||||
$this->input->next();
|
||||
} else {
|
||||
$this->input = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// no input to read on resource, buffer is empty
|
||||
if (null === $this->input && !isset($this->inputBuffer[0])) {
|
||||
if (!isset($this->inputBuffer[0]) && !($this->input instanceof \Iterator ? $this->input->valid() : $this->input)) {
|
||||
$this->input = null;
|
||||
fclose($this->pipes[0]);
|
||||
unset($this->pipes[0]);
|
||||
}
|
||||
|
||||
if (!$w) {
|
||||
} elseif (!$w) {
|
||||
return array($this->pipes[0]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function handleError($type, $msg)
|
||||
{
|
||||
$this->lastError = $msg;
|
||||
}
|
||||
}
|
||||
|
@@ -53,6 +53,13 @@ interface PipesInterface
|
||||
*/
|
||||
public function areOpen();
|
||||
|
||||
/**
|
||||
* Returns if pipes are able to read output.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function haveReadSupport();
|
||||
|
||||
/**
|
||||
* Closes file handles and pipes.
|
||||
*/
|
||||
|
39
vendor/symfony/process/Pipes/UnixPipes.php
vendored
39
vendor/symfony/process/Pipes/UnixPipes.php
vendored
@@ -22,18 +22,15 @@ use Symfony\Component\Process\Process;
|
||||
*/
|
||||
class UnixPipes extends AbstractPipes
|
||||
{
|
||||
/** @var bool */
|
||||
private $ttyMode;
|
||||
/** @var bool */
|
||||
private $ptyMode;
|
||||
/** @var bool */
|
||||
private $disableOutput;
|
||||
private $haveReadSupport;
|
||||
|
||||
public function __construct($ttyMode, $ptyMode, $input, $disableOutput)
|
||||
public function __construct($ttyMode, $ptyMode, $input, $haveReadSupport)
|
||||
{
|
||||
$this->ttyMode = (bool) $ttyMode;
|
||||
$this->ptyMode = (bool) $ptyMode;
|
||||
$this->disableOutput = (bool) $disableOutput;
|
||||
$this->haveReadSupport = (bool) $haveReadSupport;
|
||||
|
||||
parent::__construct($input);
|
||||
}
|
||||
@@ -48,7 +45,7 @@ class UnixPipes extends AbstractPipes
|
||||
*/
|
||||
public function getDescriptors()
|
||||
{
|
||||
if ($this->disableOutput) {
|
||||
if (!$this->haveReadSupport) {
|
||||
$nullstream = fopen('/dev/null', 'c');
|
||||
|
||||
return array(
|
||||
@@ -102,7 +99,9 @@ class UnixPipes extends AbstractPipes
|
||||
unset($r[0]);
|
||||
|
||||
// let's have a look if something changed in streams
|
||||
if (($r || $w) && false === $n = @stream_select($r, $w, $e, 0, $blocking ? Process::TIMEOUT_PRECISION * 1E6 : 0)) {
|
||||
set_error_handler(array($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
|
||||
// otherwise, an error occurred, let's reset pipes
|
||||
if (!$this->hasSystemCallBeenInterrupted()) {
|
||||
@@ -111,6 +110,7 @@ class UnixPipes extends AbstractPipes
|
||||
|
||||
return $read;
|
||||
}
|
||||
restore_error_handler();
|
||||
|
||||
foreach ($r as $pipe) {
|
||||
// prior PHP 5.4 the array passed to stream_select is modified and
|
||||
@@ -120,7 +120,7 @@ class UnixPipes extends AbstractPipes
|
||||
do {
|
||||
$data = fread($pipe, self::CHUNK_SIZE);
|
||||
$read[$type] .= $data;
|
||||
} while (isset($data[0]));
|
||||
} while (isset($data[0]) && ($close || isset($data[self::CHUNK_SIZE - 1])));
|
||||
|
||||
if (!isset($read[$type][0])) {
|
||||
unset($read[$type]);
|
||||
@@ -135,6 +135,14 @@ class UnixPipes extends AbstractPipes
|
||||
return $read;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function haveReadSupport()
|
||||
{
|
||||
return $this->haveReadSupport;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -142,17 +150,4 @@ class UnixPipes extends AbstractPipes
|
||||
{
|
||||
return (bool) $this->pipes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new UnixPipes instance.
|
||||
*
|
||||
* @param Process $process
|
||||
* @param string|resource $input
|
||||
*
|
||||
* @return UnixPipes
|
||||
*/
|
||||
public static function create(Process $process, $input)
|
||||
{
|
||||
return new static($process->isTty(), $process->isPty(), $input, $process->isOutputDisabled());
|
||||
}
|
||||
}
|
||||
|
50
vendor/symfony/process/Pipes/WindowsPipes.php
vendored
50
vendor/symfony/process/Pipes/WindowsPipes.php
vendored
@@ -11,8 +11,8 @@
|
||||
|
||||
namespace Symfony\Component\Process\Pipes;
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
use Symfony\Component\Process\Exception\RuntimeException;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
/**
|
||||
* WindowsPipes implementation uses temporary files as handles.
|
||||
@@ -26,23 +26,19 @@ use Symfony\Component\Process\Exception\RuntimeException;
|
||||
*/
|
||||
class WindowsPipes extends AbstractPipes
|
||||
{
|
||||
/** @var array */
|
||||
private $files = array();
|
||||
/** @var array */
|
||||
private $fileHandles = array();
|
||||
/** @var array */
|
||||
private $readBytes = array(
|
||||
Process::STDOUT => 0,
|
||||
Process::STDERR => 0,
|
||||
);
|
||||
/** @var bool */
|
||||
private $disableOutput;
|
||||
private $haveReadSupport;
|
||||
|
||||
public function __construct($disableOutput, $input)
|
||||
public function __construct($input, $haveReadSupport)
|
||||
{
|
||||
$this->disableOutput = (bool) $disableOutput;
|
||||
$this->haveReadSupport = (bool) $haveReadSupport;
|
||||
|
||||
if (!$this->disableOutput) {
|
||||
if ($this->haveReadSupport) {
|
||||
// Fix for PHP bug #51800: reading from STDOUT pipe hangs forever on Windows if the output is too big.
|
||||
// Workaround for this problem is to use temporary files instead of pipes on Windows platform.
|
||||
//
|
||||
@@ -51,9 +47,10 @@ class WindowsPipes extends AbstractPipes
|
||||
Process::STDOUT => Process::OUT,
|
||||
Process::STDERR => Process::ERR,
|
||||
);
|
||||
$tmpCheck = false;
|
||||
$tmpDir = sys_get_temp_dir();
|
||||
$error = 'unknown reason';
|
||||
set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
|
||||
$lastError = 'unknown reason';
|
||||
set_error_handler(function ($type, $msg) use (&$lastError) { $lastError = $msg; });
|
||||
for ($i = 0;; ++$i) {
|
||||
foreach ($pipes as $pipe => $name) {
|
||||
$file = sprintf('%s\\sf_proc_%02X.%s', $tmpDir, $i, $name);
|
||||
@@ -61,7 +58,11 @@ class WindowsPipes extends AbstractPipes
|
||||
continue 2;
|
||||
}
|
||||
$h = fopen($file, 'xb');
|
||||
if (!$h && false === strpos($error, 'File exists')) {
|
||||
if (!$h) {
|
||||
$error = $lastError;
|
||||
if ($tmpCheck || $tmpCheck = unlink(tempnam(false, 'sf_check_'))) {
|
||||
continue;
|
||||
}
|
||||
restore_error_handler();
|
||||
throw new RuntimeException(sprintf('A temporary file could not be opened to write the process output: %s', $error));
|
||||
}
|
||||
@@ -92,7 +93,7 @@ class WindowsPipes extends AbstractPipes
|
||||
*/
|
||||
public function getDescriptors()
|
||||
{
|
||||
if ($this->disableOutput) {
|
||||
if (!$this->haveReadSupport) {
|
||||
$nullstream = fopen('NUL', 'c');
|
||||
|
||||
return array(
|
||||
@@ -140,7 +141,7 @@ class WindowsPipes extends AbstractPipes
|
||||
$data = stream_get_contents($fileHandle, -1, $this->readBytes[$type]);
|
||||
|
||||
if (isset($data[0])) {
|
||||
$this->readBytes[$type] += strlen($data);
|
||||
$this->readBytes[$type] += \strlen($data);
|
||||
$read[$type] = $data;
|
||||
}
|
||||
if ($close) {
|
||||
@@ -152,6 +153,14 @@ class WindowsPipes extends AbstractPipes
|
||||
return $read;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function haveReadSupport()
|
||||
{
|
||||
return $this->haveReadSupport;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -172,19 +181,6 @@ class WindowsPipes extends AbstractPipes
|
||||
$this->fileHandles = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new WindowsPipes instance.
|
||||
*
|
||||
* @param Process $process The process
|
||||
* @param $input
|
||||
*
|
||||
* @return WindowsPipes
|
||||
*/
|
||||
public static function create(Process $process, $input)
|
||||
{
|
||||
return new static($process->isOutputDisabled(), $input);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes temporary files.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user