update2
This commit is contained in:
parent
98419bd18d
commit
8a69e45efa
4919 changed files with 28311 additions and 224136 deletions
163
pfosten/vendor/symfony/process/Process.php
vendored
Executable file → Normal file
163
pfosten/vendor/symfony/process/Process.php
vendored
Executable file → Normal file
|
|
@ -87,8 +87,6 @@ class Process implements \IteratorAggregate
|
|||
* Exit codes translation table.
|
||||
*
|
||||
* User-defined errors must use exit codes in the 64-113 range.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $exitCodes = array(
|
||||
0 => 'OK',
|
||||
|
|
@ -134,8 +132,6 @@ class Process implements \IteratorAggregate
|
|||
);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string|array $commandline The command line to run
|
||||
* @param string|null $cwd The working directory or null to use the working dir of the current PHP process
|
||||
* @param array|null $env The environment variables or null to use the same environment as the current PHP process
|
||||
|
|
@ -147,7 +143,7 @@ class Process implements \IteratorAggregate
|
|||
*/
|
||||
public function __construct($commandline, $cwd = null, array $env = null, $input = null, $timeout = 60, array $options = null)
|
||||
{
|
||||
if (!function_exists('proc_open')) {
|
||||
if (!\function_exists('proc_open')) {
|
||||
throw new RuntimeException('The Process class relies on proc_open, which is not available on your PHP installation.');
|
||||
}
|
||||
|
||||
|
|
@ -158,7 +154,7 @@ class Process implements \IteratorAggregate
|
|||
// on Gnu/Linux, PHP builds with --enable-maintainer-zts are also affected
|
||||
// @see : https://bugs.php.net/bug.php?id=51800
|
||||
// @see : https://bugs.php.net/bug.php?id=50524
|
||||
if (null === $this->cwd && (defined('ZEND_THREAD_SAFE') || '\\' === DIRECTORY_SEPARATOR)) {
|
||||
if (null === $this->cwd && (\defined('ZEND_THREAD_SAFE') || '\\' === \DIRECTORY_SEPARATOR)) {
|
||||
$this->cwd = getcwd();
|
||||
}
|
||||
if (null !== $env) {
|
||||
|
|
@ -167,11 +163,11 @@ class Process implements \IteratorAggregate
|
|||
|
||||
$this->setInput($input);
|
||||
$this->setTimeout($timeout);
|
||||
$this->useFileHandles = '\\' === DIRECTORY_SEPARATOR;
|
||||
$this->useFileHandles = '\\' === \DIRECTORY_SEPARATOR;
|
||||
$this->pty = false;
|
||||
$this->enhanceSigchildCompatibility = '\\' !== DIRECTORY_SEPARATOR && $this->isSigchildEnabled();
|
||||
$this->enhanceSigchildCompatibility = '\\' !== \DIRECTORY_SEPARATOR && $this->isSigchildEnabled();
|
||||
if (null !== $options) {
|
||||
@trigger_error(sprintf('The $options parameter of the %s constructor is deprecated since version 3.3 and will be removed in 4.0.', __CLASS__), E_USER_DEPRECATED);
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
|
@ -210,7 +206,7 @@ class Process implements \IteratorAggregate
|
|||
*/
|
||||
public function run($callback = null/*, array $env = array()*/)
|
||||
{
|
||||
$env = 1 < func_num_args() ? func_get_arg(1) : null;
|
||||
$env = 1 < \func_num_args() ? func_get_arg(1) : null;
|
||||
$this->start($callback, $env);
|
||||
|
||||
return $this->wait();
|
||||
|
|
@ -237,7 +233,7 @@ class Process implements \IteratorAggregate
|
|||
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;
|
||||
$env = 1 < \func_num_args() ? func_get_arg(1) : null;
|
||||
|
||||
if (0 !== $this->run($callback, $env)) {
|
||||
throw new ProcessFailedException($this);
|
||||
|
|
@ -271,13 +267,13 @@ class Process implements \IteratorAggregate
|
|||
if ($this->isRunning()) {
|
||||
throw new RuntimeException('Process is already running');
|
||||
}
|
||||
if (2 <= func_num_args()) {
|
||||
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()[0]->name)) {
|
||||
@trigger_error(sprintf('The %s::start() method expects a second "$env" argument since version 3.3. It will be made mandatory in 4.0.', static::class), E_USER_DEPRECATED);
|
||||
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;
|
||||
|
|
@ -290,10 +286,10 @@ class Process implements \IteratorAggregate
|
|||
$descriptors = $this->getDescriptors();
|
||||
$inheritEnv = $this->inheritEnv;
|
||||
|
||||
if (is_array($commandline = $this->commandline)) {
|
||||
if (\is_array($commandline = $this->commandline)) {
|
||||
$commandline = implode(' ', array_map(array($this, 'escapeArgument'), $commandline));
|
||||
|
||||
if ('\\' !== DIRECTORY_SEPARATOR) {
|
||||
if ('\\' !== \DIRECTORY_SEPARATOR) {
|
||||
// exec is mandatory to deal with sending a signal to the process
|
||||
$commandline = 'exec '.$commandline;
|
||||
}
|
||||
|
|
@ -308,19 +304,16 @@ class Process implements \IteratorAggregate
|
|||
$inheritEnv = true;
|
||||
}
|
||||
|
||||
$envBackup = array();
|
||||
if (null !== $env && $inheritEnv) {
|
||||
foreach ($env as $k => $v) {
|
||||
$envBackup[$k] = getenv($k);
|
||||
putenv(false === $v || null === $v ? $k : "$k=$v");
|
||||
}
|
||||
$env = null;
|
||||
$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) {
|
||||
if ('\\' === \DIRECTORY_SEPARATOR && $this->enhanceWindowsCompatibility) {
|
||||
$this->options['bypass_shell'] = true;
|
||||
$commandline = $this->prepareWindowsCommandLine($commandline, $envBackup, $env);
|
||||
$commandline = $this->prepareWindowsCommandLine($commandline, $env);
|
||||
} elseif (!$this->useFileHandles && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
|
||||
// last exit code is output on the fourth pipe and caught to work around --enable-sigchild
|
||||
$descriptors[3] = array('pipe', 'w');
|
||||
|
|
@ -333,14 +326,24 @@ class Process implements \IteratorAggregate
|
|||
// @see : https://bugs.php.net/69442
|
||||
$ptsWorkaround = fopen(__FILE__, 'r');
|
||||
}
|
||||
|
||||
$this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $env, $this->options);
|
||||
|
||||
foreach ($envBackup as $k => $v) {
|
||||
putenv(false === $v ? $k : "$k=$v");
|
||||
if (\defined('HHVM_VERSION')) {
|
||||
$envPairs = $env;
|
||||
} else {
|
||||
$envPairs = array();
|
||||
foreach ($env as $k => $v) {
|
||||
if (false !== $v) {
|
||||
$envPairs[] = $k.'='.$v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_resource($this->process)) {
|
||||
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);
|
||||
}
|
||||
|
||||
$this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $envPairs, $this->options);
|
||||
|
||||
if (!\is_resource($this->process)) {
|
||||
throw new RuntimeException('Unable to launch a new process.');
|
||||
}
|
||||
$this->status = self::STATUS_STARTED;
|
||||
|
|
@ -380,7 +383,7 @@ class Process implements \IteratorAggregate
|
|||
if ($this->isRunning()) {
|
||||
throw new RuntimeException('Process is already running');
|
||||
}
|
||||
$env = 1 < func_num_args() ? func_get_arg(1) : null;
|
||||
$env = 1 < \func_num_args() ? func_get_arg(1) : null;
|
||||
|
||||
$process = clone $this;
|
||||
$process->start($callback, $env);
|
||||
|
|
@ -419,8 +422,8 @@ class Process implements \IteratorAggregate
|
|||
|
||||
do {
|
||||
$this->checkTimeout();
|
||||
$running = '\\' === DIRECTORY_SEPARATOR ? $this->isRunning() : $this->processPipes->areOpen();
|
||||
$this->readPipes($running, '\\' !== DIRECTORY_SEPARATOR || !$running);
|
||||
$running = '\\' === \DIRECTORY_SEPARATOR ? $this->isRunning() : $this->processPipes->areOpen();
|
||||
$this->readPipes($running, '\\' !== \DIRECTORY_SEPARATOR || !$running);
|
||||
} while ($running);
|
||||
|
||||
while ($this->isRunning()) {
|
||||
|
|
@ -831,7 +834,7 @@ class Process implements \IteratorAggregate
|
|||
*/
|
||||
public function isStarted()
|
||||
{
|
||||
return $this->status != self::STATUS_READY;
|
||||
return self::STATUS_READY != $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -843,7 +846,7 @@ class Process implements \IteratorAggregate
|
|||
{
|
||||
$this->updateStatus(false);
|
||||
|
||||
return $this->status == self::STATUS_TERMINATED;
|
||||
return self::STATUS_TERMINATED == $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -936,7 +939,7 @@ class Process implements \IteratorAggregate
|
|||
*/
|
||||
public function getCommandLine()
|
||||
{
|
||||
return is_array($this->commandline) ? implode(' ', array_map(array($this, 'escapeArgument'), $this->commandline)) : $this->commandline;
|
||||
return \is_array($this->commandline) ? implode(' ', array_map(array($this, 'escapeArgument'), $this->commandline)) : $this->commandline;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1025,7 +1028,7 @@ class Process implements \IteratorAggregate
|
|||
*/
|
||||
public function setTty($tty)
|
||||
{
|
||||
if ('\\' === DIRECTORY_SEPARATOR && $tty) {
|
||||
if ('\\' === \DIRECTORY_SEPARATOR && $tty) {
|
||||
throw new RuntimeException('TTY mode is not supported on Windows platform.');
|
||||
}
|
||||
if ($tty) {
|
||||
|
|
@ -1122,7 +1125,7 @@ class Process implements \IteratorAggregate
|
|||
/**
|
||||
* Sets the environment variables.
|
||||
*
|
||||
* An environment variable value should be a string.
|
||||
* Each environment variable value should be a string.
|
||||
* If it is an array, the variable is ignored.
|
||||
* If it is false or null, it will be removed when
|
||||
* env vars are otherwise inherited.
|
||||
|
|
@ -1138,7 +1141,7 @@ class Process implements \IteratorAggregate
|
|||
{
|
||||
// Process can not handle env values that are arrays
|
||||
$env = array_filter($env, function ($value) {
|
||||
return !is_array($value);
|
||||
return !\is_array($value);
|
||||
});
|
||||
|
||||
$this->env = $env;
|
||||
|
|
@ -1161,7 +1164,7 @@ class Process implements \IteratorAggregate
|
|||
*
|
||||
* This content will be passed to the underlying process standard input.
|
||||
*
|
||||
* @param resource|scalar|\Traversable|null $input The content
|
||||
* @param string|int|float|bool|resource|\Traversable|null $input The content
|
||||
*
|
||||
* @return self The current Process instance
|
||||
*
|
||||
|
|
@ -1187,7 +1190,7 @@ class Process implements \IteratorAggregate
|
|||
*/
|
||||
public function getOptions()
|
||||
{
|
||||
@trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED);
|
||||
@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;
|
||||
}
|
||||
|
|
@ -1203,7 +1206,7 @@ class Process implements \IteratorAggregate
|
|||
*/
|
||||
public function setOptions(array $options)
|
||||
{
|
||||
@trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED);
|
||||
@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;
|
||||
|
||||
|
|
@ -1221,7 +1224,7 @@ class Process implements \IteratorAggregate
|
|||
*/
|
||||
public function getEnhanceWindowsCompatibility()
|
||||
{
|
||||
@trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Enhanced Windows compatibility will always be enabled.', __METHOD__), E_USER_DEPRECATED);
|
||||
@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;
|
||||
}
|
||||
|
|
@ -1237,7 +1240,7 @@ class Process implements \IteratorAggregate
|
|||
*/
|
||||
public function setEnhanceWindowsCompatibility($enhance)
|
||||
{
|
||||
@trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Enhanced Windows compatibility will always be enabled.', __METHOD__), E_USER_DEPRECATED);
|
||||
@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;
|
||||
|
||||
|
|
@ -1253,7 +1256,7 @@ class Process implements \IteratorAggregate
|
|||
*/
|
||||
public function getEnhanceSigchildCompatibility()
|
||||
{
|
||||
@trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Sigchild compatibility will always be enabled.', __METHOD__), E_USER_DEPRECATED);
|
||||
@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;
|
||||
}
|
||||
|
|
@ -1273,7 +1276,7 @@ class Process implements \IteratorAggregate
|
|||
*/
|
||||
public function setEnhanceSigchildCompatibility($enhance)
|
||||
{
|
||||
@trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Sigchild compatibility will always be enabled.', __METHOD__), E_USER_DEPRECATED);
|
||||
@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;
|
||||
|
||||
|
|
@ -1307,7 +1310,7 @@ class Process implements \IteratorAggregate
|
|||
*/
|
||||
public function areEnvironmentVariablesInherited()
|
||||
{
|
||||
@trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Environment variables will always be inherited.', __METHOD__), E_USER_DEPRECATED);
|
||||
@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;
|
||||
}
|
||||
|
|
@ -1322,7 +1325,7 @@ class Process implements \IteratorAggregate
|
|||
*/
|
||||
public function checkTimeout()
|
||||
{
|
||||
if ($this->status !== self::STATUS_STARTED) {
|
||||
if (self::STATUS_STARTED !== $this->status) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1352,7 +1355,7 @@ class Process implements \IteratorAggregate
|
|||
return $result;
|
||||
}
|
||||
|
||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
return $result = false;
|
||||
}
|
||||
|
||||
|
|
@ -1369,7 +1372,7 @@ class Process implements \IteratorAggregate
|
|||
if ($this->input instanceof \Iterator) {
|
||||
$this->input->rewind();
|
||||
}
|
||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$this->processPipes = new WindowsPipes($this->input, !$this->outputDisabled || $this->hasCallback);
|
||||
} else {
|
||||
$this->processPipes = new UnixPipes($this->isTty(), $this->isPty(), $this->input, !$this->outputDisabled || $this->hasCallback);
|
||||
|
|
@ -1393,7 +1396,7 @@ class Process implements \IteratorAggregate
|
|||
if ($this->outputDisabled) {
|
||||
return function ($type, $data) use ($callback) {
|
||||
if (null !== $callback) {
|
||||
call_user_func($callback, $type, $data);
|
||||
\call_user_func($callback, $type, $data);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -1408,7 +1411,7 @@ class Process implements \IteratorAggregate
|
|||
}
|
||||
|
||||
if (null !== $callback) {
|
||||
call_user_func($callback, $type, $data);
|
||||
\call_user_func($callback, $type, $data);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -1427,7 +1430,7 @@ class Process implements \IteratorAggregate
|
|||
$this->processInformation = proc_get_status($this->process);
|
||||
$running = $this->processInformation['running'];
|
||||
|
||||
$this->readPipes($running && $blocking, '\\' !== DIRECTORY_SEPARATOR || !$running);
|
||||
$this->readPipes($running && $blocking, '\\' !== \DIRECTORY_SEPARATOR || !$running);
|
||||
|
||||
if ($this->fallbackStatus && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
|
||||
$this->processInformation = $this->fallbackStatus + $this->processInformation;
|
||||
|
|
@ -1449,7 +1452,7 @@ class Process implements \IteratorAggregate
|
|||
return self::$sigchild;
|
||||
}
|
||||
|
||||
if (!function_exists('phpinfo') || defined('HHVM_VERSION')) {
|
||||
if (!\function_exists('phpinfo') || \defined('HHVM_VERSION')) {
|
||||
return self::$sigchild = false;
|
||||
}
|
||||
|
||||
|
|
@ -1513,7 +1516,7 @@ class Process implements \IteratorAggregate
|
|||
$callback = $this->callback;
|
||||
foreach ($result as $type => $data) {
|
||||
if (3 !== $type) {
|
||||
$callback($type === self::STDOUT ? self::OUT : self::ERR, $data);
|
||||
$callback(self::STDOUT === $type ? self::OUT : self::ERR, $data);
|
||||
} elseif (!isset($this->fallbackStatus['signaled'])) {
|
||||
$this->fallbackStatus['exitcode'] = (int) $data;
|
||||
}
|
||||
|
|
@ -1528,7 +1531,7 @@ class Process implements \IteratorAggregate
|
|||
private function close()
|
||||
{
|
||||
$this->processPipes->close();
|
||||
if (is_resource($this->process)) {
|
||||
if (\is_resource($this->process)) {
|
||||
proc_close($this->process);
|
||||
}
|
||||
$this->exitcode = $this->processInformation['exitcode'];
|
||||
|
|
@ -1593,7 +1596,7 @@ class Process implements \IteratorAggregate
|
|||
return false;
|
||||
}
|
||||
|
||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
exec(sprintf('taskkill /F /T /PID %d 2>&1', $pid), $output, $exitCode);
|
||||
if ($exitCode && $this->isRunning()) {
|
||||
if ($throwException) {
|
||||
|
|
@ -1605,7 +1608,7 @@ class Process implements \IteratorAggregate
|
|||
} else {
|
||||
if (!$this->enhanceSigchildCompatibility || !$this->isSigchildEnabled()) {
|
||||
$ok = @proc_terminate($this->process, $signal);
|
||||
} elseif (function_exists('posix_kill')) {
|
||||
} elseif (\function_exists('posix_kill')) {
|
||||
$ok = @posix_kill($pid, $signal);
|
||||
} elseif ($ok = proc_open(sprintf('kill -%d %d', $signal, $pid), array(2 => array('pipe', 'w')), $pipes)) {
|
||||
$ok = false === fgets($pipes[2]);
|
||||
|
|
@ -1627,20 +1630,23 @@ class Process implements \IteratorAggregate
|
|||
return true;
|
||||
}
|
||||
|
||||
private function prepareWindowsCommandLine($cmd, array &$envBackup, array &$env = null)
|
||||
private function prepareWindowsCommandLine($cmd, array &$env)
|
||||
{
|
||||
$uid = uniqid('', true);
|
||||
$varCount = 0;
|
||||
$varCache = array();
|
||||
$cmd = preg_replace_callback(
|
||||
'/"(
|
||||
'/"(?:(
|
||||
[^"%!^]*+
|
||||
(?:
|
||||
(?: !LF! | "(?:\^[%!^])?+" )
|
||||
[^"%!^]*+
|
||||
)++
|
||||
)"/x',
|
||||
function ($m) use (&$envBackup, &$env, &$varCache, &$varCount, $uid) {
|
||||
) | [^"]*+ )"/x',
|
||||
function ($m) use (&$env, &$varCache, &$varCount, $uid) {
|
||||
if (!isset($m[1])) {
|
||||
return $m[0];
|
||||
}
|
||||
if (isset($varCache[$m[0]])) {
|
||||
return $varCache[$m[0]];
|
||||
}
|
||||
|
|
@ -1655,13 +1661,7 @@ class Process implements \IteratorAggregate
|
|||
$value = '"'.preg_replace('/(\\\\*)"/', '$1$1\\"', $value).'"';
|
||||
$var = $uid.++$varCount;
|
||||
|
||||
if (null === $env) {
|
||||
putenv("$var=$value");
|
||||
} else {
|
||||
$env[$var] = $value;
|
||||
}
|
||||
|
||||
$envBackup[$var] = false;
|
||||
$env[$var] = $value;
|
||||
|
||||
return $varCache[$m[0]] = '!'.$var.'!';
|
||||
},
|
||||
|
|
@ -1681,7 +1681,7 @@ class Process implements \IteratorAggregate
|
|||
*
|
||||
* @param string $functionName The function name that was called
|
||||
*
|
||||
* @throws LogicException If the process has not run.
|
||||
* @throws LogicException if the process has not run
|
||||
*/
|
||||
private function requireProcessIsStarted($functionName)
|
||||
{
|
||||
|
|
@ -1695,7 +1695,7 @@ class Process implements \IteratorAggregate
|
|||
*
|
||||
* @param string $functionName The function name that was called
|
||||
*
|
||||
* @throws LogicException If the process is not yet terminated.
|
||||
* @throws LogicException if the process is not yet terminated
|
||||
*/
|
||||
private function requireProcessIsTerminated($functionName)
|
||||
{
|
||||
|
|
@ -1713,7 +1713,7 @@ class Process implements \IteratorAggregate
|
|||
*/
|
||||
private function escapeArgument($argument)
|
||||
{
|
||||
if ('\\' !== DIRECTORY_SEPARATOR) {
|
||||
if ('\\' !== \DIRECTORY_SEPARATOR) {
|
||||
return "'".str_replace("'", "'\\''", $argument)."'";
|
||||
}
|
||||
if ('' === $argument = (string) $argument) {
|
||||
|
|
@ -1729,4 +1729,23 @@ class Process implements \IteratorAggregate
|
|||
|
||||
return '"'.str_replace(array('"', '^', '%', '!', "\n"), array('""', '"^^"', '"^%"', '"^!"', '!LF!'), $argument).'"';
|
||||
}
|
||||
|
||||
private function getDefaultEnv()
|
||||
{
|
||||
$env = array();
|
||||
|
||||
foreach ($_SERVER as $k => $v) {
|
||||
if (\is_string($v) && false !== $v = getenv($k)) {
|
||||
$env[$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($_ENV as $k => $v) {
|
||||
if (\is_string($v)) {
|
||||
$env[$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
return $env;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue