提交代码
This commit is contained in:
3
vendor/symfony/process/.gitignore
vendored
Normal file
3
vendor/symfony/process/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
vendor/
|
||||
composer.lock
|
||||
phpunit.xml
|
||||
90
vendor/symfony/process/CHANGELOG.md
vendored
Normal file
90
vendor/symfony/process/CHANGELOG.md
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
4.2.0
|
||||
-----
|
||||
|
||||
* added the `Process::fromShellCommandline()` to run commands in a shell wrapper
|
||||
* deprecated passing a command as string when creating a `Process` instance
|
||||
* deprecated the `Process::setCommandline()` and the `PhpProcess::setPhpBinary()` methods
|
||||
* added the `Process::waitUntil()` method to wait for the process only for a
|
||||
specific output, then continue the normal execution of your application
|
||||
|
||||
4.1.0
|
||||
-----
|
||||
|
||||
* added the `Process::isTtySupported()` method that allows to check for TTY support
|
||||
* made `PhpExecutableFinder` look for the `PHP_BINARY` env var when searching the php binary
|
||||
* added the `ProcessSignaledException` class to properly catch signaled process errors
|
||||
|
||||
4.0.0
|
||||
-----
|
||||
|
||||
* environment variables will always be inherited
|
||||
* added a second `array $env = []` argument to the `start()`, `run()`,
|
||||
`mustRun()`, and `restart()` methods of the `Process` class
|
||||
* added a second `array $env = []` argument to the `start()` method of the
|
||||
`PhpProcess` class
|
||||
* the `ProcessUtils::escapeArgument()` method has been removed
|
||||
* the `areEnvironmentVariablesInherited()`, `getOptions()`, and `setOptions()`
|
||||
methods of the `Process` class have been removed
|
||||
* 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 `Symfony\Component\Process\Process` class is not
|
||||
supported anymore
|
||||
|
||||
3.4.0
|
||||
-----
|
||||
|
||||
* deprecated the ProcessBuilder class
|
||||
* deprecated calling `Process::start()` without setting a valid working directory beforehand (via `setWorkingDirectory()` or constructor)
|
||||
|
||||
3.3.0
|
||||
-----
|
||||
|
||||
* added command line arrays in the `Process` class
|
||||
* added `$env` argument to `Process::start()`, `run()`, `mustRun()` and `restart()` methods
|
||||
* deprecated the `ProcessUtils::escapeArgument()` method
|
||||
* deprecated not inheriting environment variables
|
||||
* deprecated configuring `proc_open()` options
|
||||
* deprecated configuring enhanced Windows compatibility
|
||||
* deprecated configuring enhanced sigchild compatibility
|
||||
|
||||
2.5.0
|
||||
-----
|
||||
|
||||
* added support for PTY mode
|
||||
* added the convenience method "mustRun"
|
||||
* deprecation: Process::setStdin() is deprecated in favor of Process::setInput()
|
||||
* deprecation: Process::getStdin() is deprecated in favor of Process::getInput()
|
||||
* deprecation: Process::setInput() and ProcessBuilder::setInput() do not accept non-scalar types
|
||||
|
||||
2.4.0
|
||||
-----
|
||||
|
||||
* added the ability to define an idle timeout
|
||||
|
||||
2.3.0
|
||||
-----
|
||||
|
||||
* added ProcessUtils::escapeArgument() to fix the bug in escapeshellarg() function on Windows
|
||||
* added Process::signal()
|
||||
* added Process::getPid()
|
||||
* added support for a TTY mode
|
||||
|
||||
2.2.0
|
||||
-----
|
||||
|
||||
* added ProcessBuilder::setArguments() to reset the arguments on a builder
|
||||
* added a way to retrieve the standard and error output incrementally
|
||||
* added Process:restart()
|
||||
|
||||
2.1.0
|
||||
-----
|
||||
|
||||
* added support for non-blocking processes (start(), wait(), isRunning(), stop())
|
||||
* enhanced Windows compatibility
|
||||
* added Process::getExitCodeText() that returns a string representation for
|
||||
the exit code returned by the process
|
||||
* added ProcessBuilder
|
||||
21
vendor/symfony/process/Exception/ExceptionInterface.php
vendored
Normal file
21
vendor/symfony/process/Exception/ExceptionInterface.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Exception;
|
||||
|
||||
/**
|
||||
* Marker Interface for the Process Component.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
interface ExceptionInterface extends \Throwable
|
||||
{
|
||||
}
|
||||
21
vendor/symfony/process/Exception/InvalidArgumentException.php
vendored
Normal file
21
vendor/symfony/process/Exception/InvalidArgumentException.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Exception;
|
||||
|
||||
/**
|
||||
* InvalidArgumentException for the Process Component.
|
||||
*
|
||||
* @author Romain Neutron <imprec@gmail.com>
|
||||
*/
|
||||
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
|
||||
{
|
||||
}
|
||||
21
vendor/symfony/process/Exception/LogicException.php
vendored
Normal file
21
vendor/symfony/process/Exception/LogicException.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Exception;
|
||||
|
||||
/**
|
||||
* LogicException for the Process Component.
|
||||
*
|
||||
* @author Romain Neutron <imprec@gmail.com>
|
||||
*/
|
||||
class LogicException extends \LogicException implements ExceptionInterface
|
||||
{
|
||||
}
|
||||
54
vendor/symfony/process/Exception/ProcessFailedException.php
vendored
Normal file
54
vendor/symfony/process/Exception/ProcessFailedException.php
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Exception;
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
/**
|
||||
* Exception for failed processes.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class ProcessFailedException extends RuntimeException
|
||||
{
|
||||
private $process;
|
||||
|
||||
public function __construct(Process $process)
|
||||
{
|
||||
if ($process->isSuccessful()) {
|
||||
throw new InvalidArgumentException('Expected a failed process, but the given process was successful.');
|
||||
}
|
||||
|
||||
$error = sprintf('The command "%s" failed.'."\n\nExit Code: %s(%s)\n\nWorking directory: %s",
|
||||
$process->getCommandLine(),
|
||||
$process->getExitCode(),
|
||||
$process->getExitCodeText(),
|
||||
$process->getWorkingDirectory()
|
||||
);
|
||||
|
||||
if (!$process->isOutputDisabled()) {
|
||||
$error .= sprintf("\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s",
|
||||
$process->getOutput(),
|
||||
$process->getErrorOutput()
|
||||
);
|
||||
}
|
||||
|
||||
parent::__construct($error);
|
||||
|
||||
$this->process = $process;
|
||||
}
|
||||
|
||||
public function getProcess()
|
||||
{
|
||||
return $this->process;
|
||||
}
|
||||
}
|
||||
41
vendor/symfony/process/Exception/ProcessSignaledException.php
vendored
Normal file
41
vendor/symfony/process/Exception/ProcessSignaledException.php
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Exception;
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
/**
|
||||
* Exception that is thrown when a process has been signaled.
|
||||
*
|
||||
* @author Sullivan Senechal <soullivaneuh@gmail.com>
|
||||
*/
|
||||
final class ProcessSignaledException extends RuntimeException
|
||||
{
|
||||
private $process;
|
||||
|
||||
public function __construct(Process $process)
|
||||
{
|
||||
$this->process = $process;
|
||||
|
||||
parent::__construct(sprintf('The process has been signaled with signal "%s".', $process->getTermSignal()));
|
||||
}
|
||||
|
||||
public function getProcess(): Process
|
||||
{
|
||||
return $this->process;
|
||||
}
|
||||
|
||||
public function getSignal(): int
|
||||
{
|
||||
return $this->getProcess()->getTermSignal();
|
||||
}
|
||||
}
|
||||
69
vendor/symfony/process/Exception/ProcessTimedOutException.php
vendored
Normal file
69
vendor/symfony/process/Exception/ProcessTimedOutException.php
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Exception;
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
/**
|
||||
* Exception that is thrown when a process times out.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class ProcessTimedOutException extends RuntimeException
|
||||
{
|
||||
const TYPE_GENERAL = 1;
|
||||
const TYPE_IDLE = 2;
|
||||
|
||||
private $process;
|
||||
private $timeoutType;
|
||||
|
||||
public function __construct(Process $process, int $timeoutType)
|
||||
{
|
||||
$this->process = $process;
|
||||
$this->timeoutType = $timeoutType;
|
||||
|
||||
parent::__construct(sprintf(
|
||||
'The process "%s" exceeded the timeout of %s seconds.',
|
||||
$process->getCommandLine(),
|
||||
$this->getExceededTimeout()
|
||||
));
|
||||
}
|
||||
|
||||
public function getProcess()
|
||||
{
|
||||
return $this->process;
|
||||
}
|
||||
|
||||
public function isGeneralTimeout()
|
||||
{
|
||||
return self::TYPE_GENERAL === $this->timeoutType;
|
||||
}
|
||||
|
||||
public function isIdleTimeout()
|
||||
{
|
||||
return self::TYPE_IDLE === $this->timeoutType;
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
21
vendor/symfony/process/Exception/RuntimeException.php
vendored
Normal file
21
vendor/symfony/process/Exception/RuntimeException.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Exception;
|
||||
|
||||
/**
|
||||
* RuntimeException for the Process Component.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class RuntimeException extends \RuntimeException implements ExceptionInterface
|
||||
{
|
||||
}
|
||||
88
vendor/symfony/process/ExecutableFinder.php
vendored
Normal file
88
vendor/symfony/process/ExecutableFinder.php
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process;
|
||||
|
||||
/**
|
||||
* Generic executable finder.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class ExecutableFinder
|
||||
{
|
||||
private $suffixes = ['.exe', '.bat', '.cmd', '.com'];
|
||||
|
||||
/**
|
||||
* Replaces default suffixes of executable.
|
||||
*/
|
||||
public function setSuffixes(array $suffixes)
|
||||
{
|
||||
$this->suffixes = $suffixes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds new possible suffix to check for executable.
|
||||
*
|
||||
* @param string $suffix
|
||||
*/
|
||||
public function addSuffix($suffix)
|
||||
{
|
||||
$this->suffixes[] = $suffix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds an executable by name.
|
||||
*
|
||||
* @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 The executable path or default value
|
||||
*/
|
||||
public function find($name, $default = null, array $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
|
||||
if (@is_dir($path)) {
|
||||
$dirs[] = $path;
|
||||
} else {
|
||||
if (basename($path) == $name && @is_executable($path)) {
|
||||
return $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$dirs = array_merge(
|
||||
explode(PATH_SEPARATOR, getenv('PATH') ?: getenv('Path')),
|
||||
$extraDirs
|
||||
);
|
||||
}
|
||||
|
||||
$suffixes = [''];
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$pathExt = getenv('PATHEXT');
|
||||
$suffixes = array_merge($pathExt ? explode(PATH_SEPARATOR, $pathExt) : $this->suffixes, $suffixes);
|
||||
}
|
||||
foreach ($suffixes as $suffix) {
|
||||
foreach ($dirs as $dir) {
|
||||
if (@is_file($file = $dir.\DIRECTORY_SEPARATOR.$name.$suffix) && ('\\' === \DIRECTORY_SEPARATOR || @is_executable($file))) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
}
|
||||
90
vendor/symfony/process/InputStream.php
vendored
Normal file
90
vendor/symfony/process/InputStream.php
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process;
|
||||
|
||||
use Symfony\Component\Process\Exception\RuntimeException;
|
||||
|
||||
/**
|
||||
* Provides a way to continuously write to the input of a Process until the InputStream is closed.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class InputStream implements \IteratorAggregate
|
||||
{
|
||||
/** @var callable|null */
|
||||
private $onEmpty = null;
|
||||
private $input = [];
|
||||
private $open = true;
|
||||
|
||||
/**
|
||||
* Sets a callback that is called when the write buffer becomes empty.
|
||||
*/
|
||||
public function onEmpty(callable $onEmpty = null)
|
||||
{
|
||||
$this->onEmpty = $onEmpty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends an input to the write buffer.
|
||||
*
|
||||
* @param resource|string|int|float|bool|\Traversable|null $input The input to append as scalar,
|
||||
* stream resource or \Traversable
|
||||
*/
|
||||
public function write($input)
|
||||
{
|
||||
if (null === $input) {
|
||||
return;
|
||||
}
|
||||
if ($this->isClosed()) {
|
||||
throw new RuntimeException(sprintf('%s is closed', static::class));
|
||||
}
|
||||
$this->input[] = ProcessUtils::validateInput(__METHOD__, $input);
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the write buffer.
|
||||
*/
|
||||
public function close()
|
||||
{
|
||||
$this->open = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells whether the write buffer is closed or not.
|
||||
*/
|
||||
public function isClosed()
|
||||
{
|
||||
return !$this->open;
|
||||
}
|
||||
|
||||
public function getIterator()
|
||||
{
|
||||
$this->open = true;
|
||||
|
||||
while ($this->open || $this->input) {
|
||||
if (!$this->input) {
|
||||
yield '';
|
||||
continue;
|
||||
}
|
||||
$current = array_shift($this->input);
|
||||
|
||||
if ($current instanceof \Iterator) {
|
||||
yield from $current;
|
||||
} else {
|
||||
yield $current;
|
||||
}
|
||||
if (!$this->input && $this->open && null !== $onEmpty = $this->onEmpty) {
|
||||
$this->write($onEmpty($this));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
19
vendor/symfony/process/LICENSE
vendored
Normal file
19
vendor/symfony/process/LICENSE
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2004-2019 Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
101
vendor/symfony/process/PhpExecutableFinder.php
vendored
Normal file
101
vendor/symfony/process/PhpExecutableFinder.php
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process;
|
||||
|
||||
/**
|
||||
* An executable finder specifically designed for the PHP executable.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class PhpExecutableFinder
|
||||
{
|
||||
private $executableFinder;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->executableFinder = new ExecutableFinder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds The PHP executable.
|
||||
*
|
||||
* @param bool $includeArgs Whether or not include command arguments
|
||||
*
|
||||
* @return string|false The PHP executable path or false if it cannot be found
|
||||
*/
|
||||
public function find($includeArgs = true)
|
||||
{
|
||||
if ($php = getenv('PHP_BINARY')) {
|
||||
if (!is_executable($php)) {
|
||||
$command = '\\' === \DIRECTORY_SEPARATOR ? 'where' : 'command -v';
|
||||
if ($php = strtok(exec($command.' '.escapeshellarg($php)), PHP_EOL)) {
|
||||
if (!is_executable($php)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return $php;
|
||||
}
|
||||
|
||||
$args = $this->findArguments();
|
||||
$args = $includeArgs && $args ? ' '.implode(' ', $args) : '';
|
||||
|
||||
// PHP_BINARY return the current sapi executable
|
||||
if (PHP_BINARY && \in_array(\PHP_SAPI, ['cli', 'cli-server', 'phpdbg'], true)) {
|
||||
return PHP_BINARY.$args;
|
||||
}
|
||||
|
||||
if ($php = getenv('PHP_PATH')) {
|
||||
if (!@is_executable($php)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $php;
|
||||
}
|
||||
|
||||
if ($php = getenv('PHP_PEAR_PHP_BIN')) {
|
||||
if (@is_executable($php)) {
|
||||
return $php;
|
||||
}
|
||||
}
|
||||
|
||||
if (@is_executable($php = PHP_BINDIR.('\\' === \DIRECTORY_SEPARATOR ? '\\php.exe' : '/php'))) {
|
||||
return $php;
|
||||
}
|
||||
|
||||
$dirs = [PHP_BINDIR];
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$dirs[] = 'C:\xampp\php\\';
|
||||
}
|
||||
|
||||
return $this->executableFinder->find('php', false, $dirs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the PHP executable arguments.
|
||||
*
|
||||
* @return array The PHP executable arguments
|
||||
*/
|
||||
public function findArguments()
|
||||
{
|
||||
$arguments = [];
|
||||
if ('phpdbg' === \PHP_SAPI) {
|
||||
$arguments[] = '-qrr';
|
||||
}
|
||||
|
||||
return $arguments;
|
||||
}
|
||||
}
|
||||
75
vendor/symfony/process/PhpProcess.php
vendored
Normal file
75
vendor/symfony/process/PhpProcess.php
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process;
|
||||
|
||||
use Symfony\Component\Process\Exception\RuntimeException;
|
||||
|
||||
/**
|
||||
* PhpProcess runs a PHP script in an independent process.
|
||||
*
|
||||
* $p = new PhpProcess('<?php echo "foo"; ?>');
|
||||
* $p->run();
|
||||
* print $p->getOutput()."\n";
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class PhpProcess extends Process
|
||||
{
|
||||
/**
|
||||
* @param string $script The PHP script to run (as a string)
|
||||
* @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
|
||||
* @param int $timeout The timeout in seconds
|
||||
* @param array|null $php Path to the PHP binary to use with any additional arguments
|
||||
*/
|
||||
public function __construct(string $script, string $cwd = null, array $env = null, int $timeout = 60, array $php = null)
|
||||
{
|
||||
if (null === $php) {
|
||||
$executableFinder = new PhpExecutableFinder();
|
||||
$php = $executableFinder->find(false);
|
||||
$php = false === $php ? null : array_merge([$php], $executableFinder->findArguments());
|
||||
}
|
||||
if ('phpdbg' === \PHP_SAPI) {
|
||||
$file = tempnam(sys_get_temp_dir(), 'dbg');
|
||||
file_put_contents($file, $script);
|
||||
register_shutdown_function('unlink', $file);
|
||||
$php[] = $file;
|
||||
$script = null;
|
||||
}
|
||||
|
||||
parent::__construct($php, $cwd, $env, $script, $timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the path to the PHP binary to use.
|
||||
*
|
||||
* @deprecated since Symfony 4.2, use the $php argument of the constructor instead.
|
||||
*/
|
||||
public function setPhpBinary($php)
|
||||
{
|
||||
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the $php argument of the constructor instead.', __METHOD__), E_USER_DEPRECATED);
|
||||
|
||||
$this->setCommandLine($php);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function start(callable $callback = null, array $env = [])
|
||||
{
|
||||
if (null === $this->getCommandLine()) {
|
||||
throw new RuntimeException('Unable to find the PHP executable.');
|
||||
}
|
||||
|
||||
parent::start($callback, $env);
|
||||
}
|
||||
}
|
||||
182
vendor/symfony/process/Pipes/AbstractPipes.php
vendored
Normal file
182
vendor/symfony/process/Pipes/AbstractPipes.php
vendored
Normal file
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Pipes;
|
||||
|
||||
use Symfony\Component\Process\Exception\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* @author Romain Neutron <imprec@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
abstract class AbstractPipes implements PipesInterface
|
||||
{
|
||||
public $pipes = [];
|
||||
|
||||
private $inputBuffer = '';
|
||||
private $input;
|
||||
private $blocked = true;
|
||||
private $lastError;
|
||||
|
||||
/**
|
||||
* @param resource|string|int|float|bool|\Iterator|null $input
|
||||
*/
|
||||
public function __construct($input)
|
||||
{
|
||||
if (\is_resource($input) || $input instanceof \Iterator) {
|
||||
$this->input = $input;
|
||||
} elseif (\is_string($input)) {
|
||||
$this->inputBuffer = $input;
|
||||
} else {
|
||||
$this->inputBuffer = (string) $input;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function close()
|
||||
{
|
||||
foreach ($this->pipes as $pipe) {
|
||||
fclose($pipe);
|
||||
}
|
||||
$this->pipes = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if a system call has been interrupted.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function hasSystemCallBeenInterrupted()
|
||||
{
|
||||
$lastError = $this->lastError;
|
||||
$this->lastError = null;
|
||||
|
||||
// stream_select returns false when the `select` system call is interrupted by an incoming signal
|
||||
return null !== $lastError && false !== stripos($lastError, 'interrupted system call');
|
||||
}
|
||||
|
||||
/**
|
||||
* Unblocks streams.
|
||||
*/
|
||||
protected function unblock()
|
||||
{
|
||||
if (!$this->blocked) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($this->pipes as $pipe) {
|
||||
stream_set_blocking($pipe, 0);
|
||||
}
|
||||
if (\is_resource($this->input)) {
|
||||
stream_set_blocking($this->input, 0);
|
||||
}
|
||||
|
||||
$this->blocked = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes input to stdin.
|
||||
*
|
||||
* @return array|null
|
||||
*
|
||||
* @throws InvalidArgumentException When an input iterator yields a non supported value
|
||||
*/
|
||||
protected function write()
|
||||
{
|
||||
if (!isset($this->pipes[0])) {
|
||||
return null;
|
||||
}
|
||||
$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 = [];
|
||||
$w = [$this->pipes[0]];
|
||||
|
||||
// let's have a look if something changed in streams
|
||||
if (false === @stream_select($r, $w, $e, 0, 0)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach ($w as $stdin) {
|
||||
if (isset($this->inputBuffer[0])) {
|
||||
$written = fwrite($stdin, $this->inputBuffer);
|
||||
$this->inputBuffer = substr($this->inputBuffer, $written);
|
||||
if (isset($this->inputBuffer[0])) {
|
||||
return [$this->pipes[0]];
|
||||
}
|
||||
}
|
||||
|
||||
if ($input) {
|
||||
for (;;) {
|
||||
$data = fread($input, self::CHUNK_SIZE);
|
||||
if (!isset($data[0])) {
|
||||
break;
|
||||
}
|
||||
$written = fwrite($stdin, $data);
|
||||
$data = substr($data, $written);
|
||||
if (isset($data[0])) {
|
||||
$this->inputBuffer = $data;
|
||||
|
||||
return [$this->pipes[0]];
|
||||
}
|
||||
}
|
||||
if (feof($input)) {
|
||||
if ($this->input instanceof \Iterator) {
|
||||
$this->input->next();
|
||||
} else {
|
||||
$this->input = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// no input to read on resource, buffer is empty
|
||||
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]);
|
||||
} elseif (!$w) {
|
||||
return [$this->pipes[0]];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function handleError($type, $msg)
|
||||
{
|
||||
$this->lastError = $msg;
|
||||
}
|
||||
}
|
||||
67
vendor/symfony/process/Pipes/PipesInterface.php
vendored
Normal file
67
vendor/symfony/process/Pipes/PipesInterface.php
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Pipes;
|
||||
|
||||
/**
|
||||
* PipesInterface manages descriptors and pipes for the use of proc_open.
|
||||
*
|
||||
* @author Romain Neutron <imprec@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
interface PipesInterface
|
||||
{
|
||||
const CHUNK_SIZE = 16384;
|
||||
|
||||
/**
|
||||
* Returns an array of descriptors for the use of proc_open.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getDescriptors();
|
||||
|
||||
/**
|
||||
* Returns an array of filenames indexed by their related stream in case these pipes use temporary files.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getFiles();
|
||||
|
||||
/**
|
||||
* Reads data in file handles and pipes.
|
||||
*
|
||||
* @param bool $blocking Whether to use blocking calls or not
|
||||
* @param bool $close Whether to close pipes if they've reached EOF
|
||||
*
|
||||
* @return string[] An array of read data indexed by their fd
|
||||
*/
|
||||
public function readAndWrite($blocking, $close = false);
|
||||
|
||||
/**
|
||||
* Returns if the current state has open file handles or pipes.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function areOpen();
|
||||
|
||||
/**
|
||||
* Returns if pipes are able to read output.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function haveReadSupport();
|
||||
|
||||
/**
|
||||
* Closes file handles and pipes.
|
||||
*/
|
||||
public function close();
|
||||
}
|
||||
153
vendor/symfony/process/Pipes/UnixPipes.php
vendored
Normal file
153
vendor/symfony/process/Pipes/UnixPipes.php
vendored
Normal file
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Pipes;
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
/**
|
||||
* UnixPipes implementation uses unix pipes as handles.
|
||||
*
|
||||
* @author Romain Neutron <imprec@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class UnixPipes extends AbstractPipes
|
||||
{
|
||||
private $ttyMode;
|
||||
private $ptyMode;
|
||||
private $haveReadSupport;
|
||||
|
||||
public function __construct(?bool $ttyMode, bool $ptyMode, $input, bool $haveReadSupport)
|
||||
{
|
||||
$this->ttyMode = $ttyMode;
|
||||
$this->ptyMode = $ptyMode;
|
||||
$this->haveReadSupport = $haveReadSupport;
|
||||
|
||||
parent::__construct($input);
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
$this->close();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDescriptors()
|
||||
{
|
||||
if (!$this->haveReadSupport) {
|
||||
$nullstream = fopen('/dev/null', 'c');
|
||||
|
||||
return [
|
||||
['pipe', 'r'],
|
||||
$nullstream,
|
||||
$nullstream,
|
||||
];
|
||||
}
|
||||
|
||||
if ($this->ttyMode) {
|
||||
return [
|
||||
['file', '/dev/tty', 'r'],
|
||||
['file', '/dev/tty', 'w'],
|
||||
['file', '/dev/tty', 'w'],
|
||||
];
|
||||
}
|
||||
|
||||
if ($this->ptyMode && Process::isPtySupported()) {
|
||||
return [
|
||||
['pty'],
|
||||
['pty'],
|
||||
['pty'],
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
['pipe', 'r'],
|
||||
['pipe', 'w'], // stdout
|
||||
['pipe', 'w'], // stderr
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFiles()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function readAndWrite($blocking, $close = false)
|
||||
{
|
||||
$this->unblock();
|
||||
$w = $this->write();
|
||||
|
||||
$read = $e = [];
|
||||
$r = $this->pipes;
|
||||
unset($r[0]);
|
||||
|
||||
// let's have a look if something changed in streams
|
||||
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
|
||||
// otherwise, an error occurred, let's reset pipes
|
||||
if (!$this->hasSystemCallBeenInterrupted()) {
|
||||
$this->pipes = [];
|
||||
}
|
||||
|
||||
return $read;
|
||||
}
|
||||
restore_error_handler();
|
||||
|
||||
foreach ($r as $pipe) {
|
||||
// prior PHP 5.4 the array passed to stream_select is modified and
|
||||
// lose key association, we have to find back the key
|
||||
$read[$type = array_search($pipe, $this->pipes, true)] = '';
|
||||
|
||||
do {
|
||||
$data = fread($pipe, self::CHUNK_SIZE);
|
||||
$read[$type] .= $data;
|
||||
} while (isset($data[0]) && ($close || isset($data[self::CHUNK_SIZE - 1])));
|
||||
|
||||
if (!isset($read[$type][0])) {
|
||||
unset($read[$type]);
|
||||
}
|
||||
|
||||
if ($close && feof($pipe)) {
|
||||
fclose($pipe);
|
||||
unset($this->pipes[$type]);
|
||||
}
|
||||
}
|
||||
|
||||
return $read;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function haveReadSupport()
|
||||
{
|
||||
return $this->haveReadSupport;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function areOpen()
|
||||
{
|
||||
return (bool) $this->pipes;
|
||||
}
|
||||
}
|
||||
191
vendor/symfony/process/Pipes/WindowsPipes.php
vendored
Normal file
191
vendor/symfony/process/Pipes/WindowsPipes.php
vendored
Normal file
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Pipes;
|
||||
|
||||
use Symfony\Component\Process\Exception\RuntimeException;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
/**
|
||||
* WindowsPipes implementation uses temporary files as handles.
|
||||
*
|
||||
* @see https://bugs.php.net/51800
|
||||
* @see https://bugs.php.net/65650
|
||||
*
|
||||
* @author Romain Neutron <imprec@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class WindowsPipes extends AbstractPipes
|
||||
{
|
||||
private $files = [];
|
||||
private $fileHandles = [];
|
||||
private $lockHandles = [];
|
||||
private $readBytes = [
|
||||
Process::STDOUT => 0,
|
||||
Process::STDERR => 0,
|
||||
];
|
||||
private $haveReadSupport;
|
||||
|
||||
public function __construct($input, bool $haveReadSupport)
|
||||
{
|
||||
$this->haveReadSupport = $haveReadSupport;
|
||||
|
||||
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.
|
||||
//
|
||||
// @see https://bugs.php.net/51800
|
||||
$pipes = [
|
||||
Process::STDOUT => Process::OUT,
|
||||
Process::STDERR => Process::ERR,
|
||||
];
|
||||
$tmpDir = sys_get_temp_dir();
|
||||
$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);
|
||||
|
||||
if (!$h = fopen($file.'.lock', 'w')) {
|
||||
restore_error_handler();
|
||||
throw new RuntimeException(sprintf('A temporary file could not be opened to write the process output: %s', $lastError));
|
||||
}
|
||||
if (!flock($h, LOCK_EX | LOCK_NB)) {
|
||||
continue 2;
|
||||
}
|
||||
if (isset($this->lockHandles[$pipe])) {
|
||||
flock($this->lockHandles[$pipe], LOCK_UN);
|
||||
fclose($this->lockHandles[$pipe]);
|
||||
}
|
||||
$this->lockHandles[$pipe] = $h;
|
||||
|
||||
if (!fclose(fopen($file, 'w')) || !$h = fopen($file, 'r')) {
|
||||
flock($this->lockHandles[$pipe], LOCK_UN);
|
||||
fclose($this->lockHandles[$pipe]);
|
||||
unset($this->lockHandles[$pipe]);
|
||||
continue 2;
|
||||
}
|
||||
$this->fileHandles[$pipe] = $h;
|
||||
$this->files[$pipe] = $file;
|
||||
}
|
||||
break;
|
||||
}
|
||||
restore_error_handler();
|
||||
}
|
||||
|
||||
parent::__construct($input);
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
$this->close();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDescriptors()
|
||||
{
|
||||
if (!$this->haveReadSupport) {
|
||||
$nullstream = fopen('NUL', 'c');
|
||||
|
||||
return [
|
||||
['pipe', 'r'],
|
||||
$nullstream,
|
||||
$nullstream,
|
||||
];
|
||||
}
|
||||
|
||||
// We're not using pipe on Windows platform as it hangs (https://bugs.php.net/51800)
|
||||
// We're not using file handles as it can produce corrupted output https://bugs.php.net/65650
|
||||
// So we redirect output within the commandline and pass the nul device to the process
|
||||
return [
|
||||
['pipe', 'r'],
|
||||
['file', 'NUL', 'w'],
|
||||
['file', 'NUL', 'w'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFiles()
|
||||
{
|
||||
return $this->files;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function readAndWrite($blocking, $close = false)
|
||||
{
|
||||
$this->unblock();
|
||||
$w = $this->write();
|
||||
$read = $r = $e = [];
|
||||
|
||||
if ($blocking) {
|
||||
if ($w) {
|
||||
@stream_select($r, $w, $e, 0, Process::TIMEOUT_PRECISION * 1E6);
|
||||
} elseif ($this->fileHandles) {
|
||||
usleep(Process::TIMEOUT_PRECISION * 1E6);
|
||||
}
|
||||
}
|
||||
foreach ($this->fileHandles as $type => $fileHandle) {
|
||||
$data = stream_get_contents($fileHandle, -1, $this->readBytes[$type]);
|
||||
|
||||
if (isset($data[0])) {
|
||||
$this->readBytes[$type] += \strlen($data);
|
||||
$read[$type] = $data;
|
||||
}
|
||||
if ($close) {
|
||||
ftruncate($fileHandle, 0);
|
||||
fclose($fileHandle);
|
||||
flock($this->lockHandles[$type], LOCK_UN);
|
||||
fclose($this->lockHandles[$type]);
|
||||
unset($this->fileHandles[$type], $this->lockHandles[$type]);
|
||||
}
|
||||
}
|
||||
|
||||
return $read;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function haveReadSupport()
|
||||
{
|
||||
return $this->haveReadSupport;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function areOpen()
|
||||
{
|
||||
return $this->pipes && $this->fileHandles;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function close()
|
||||
{
|
||||
parent::close();
|
||||
foreach ($this->fileHandles as $type => $handle) {
|
||||
ftruncate($handle, 0);
|
||||
fclose($handle);
|
||||
flock($this->lockHandles[$type], LOCK_UN);
|
||||
fclose($this->lockHandles[$type]);
|
||||
}
|
||||
$this->fileHandles = $this->lockHandles = [];
|
||||
}
|
||||
}
|
||||
1645
vendor/symfony/process/Process.php
vendored
Normal file
1645
vendor/symfony/process/Process.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
69
vendor/symfony/process/ProcessUtils.php
vendored
Normal file
69
vendor/symfony/process/ProcessUtils.php
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process;
|
||||
|
||||
use Symfony\Component\Process\Exception\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* ProcessUtils is a bunch of utility methods.
|
||||
*
|
||||
* This class contains static methods only and is not meant to be instantiated.
|
||||
*
|
||||
* @author Martin Hasoň <martin.hason@gmail.com>
|
||||
*/
|
||||
class ProcessUtils
|
||||
{
|
||||
/**
|
||||
* This class should not be instantiated.
|
||||
*/
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates and normalizes a Process input.
|
||||
*
|
||||
* @param string $caller The name of method call that validates the input
|
||||
* @param mixed $input The input to validate
|
||||
*
|
||||
* @return mixed The validated input
|
||||
*
|
||||
* @throws InvalidArgumentException In case the input is not valid
|
||||
*/
|
||||
public static function validateInput($caller, $input)
|
||||
{
|
||||
if (null !== $input) {
|
||||
if (\is_resource($input)) {
|
||||
return $input;
|
||||
}
|
||||
if (\is_string($input)) {
|
||||
return $input;
|
||||
}
|
||||
if (is_scalar($input)) {
|
||||
return (string) $input;
|
||||
}
|
||||
if ($input instanceof Process) {
|
||||
return $input->getIterator($input::ITER_SKIP_ERR);
|
||||
}
|
||||
if ($input instanceof \Iterator) {
|
||||
return $input;
|
||||
}
|
||||
if ($input instanceof \Traversable) {
|
||||
return new \IteratorIterator($input);
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException(sprintf('%s only accepts strings, Traversable objects or stream resources.', $caller));
|
||||
}
|
||||
|
||||
return $input;
|
||||
}
|
||||
}
|
||||
13
vendor/symfony/process/README.md
vendored
Normal file
13
vendor/symfony/process/README.md
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
Process Component
|
||||
=================
|
||||
|
||||
The Process component executes commands in sub-processes.
|
||||
|
||||
Resources
|
||||
---------
|
||||
|
||||
* [Documentation](https://symfony.com/doc/current/components/process.html)
|
||||
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
|
||||
* [Report issues](https://github.com/symfony/symfony/issues) and
|
||||
[send Pull Requests](https://github.com/symfony/symfony/pulls)
|
||||
in the [main Symfony repository](https://github.com/symfony/symfony)
|
||||
36
vendor/symfony/process/Tests/ErrorProcessInitiator.php
vendored
Normal file
36
vendor/symfony/process/Tests/ErrorProcessInitiator.php
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Tests;
|
||||
|
||||
use Symfony\Component\Process\Exception\ProcessTimedOutException;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
require \dirname(__DIR__).'/vendor/autoload.php';
|
||||
|
||||
list('e' => $php) = getopt('e:') + ['e' => 'php'];
|
||||
|
||||
try {
|
||||
$process = new Process("exec $php -r \"echo 'ready'; trigger_error('error', E_USER_ERROR);\"");
|
||||
$process->start();
|
||||
$process->setTimeout(0.5);
|
||||
while (false === strpos($process->getOutput(), 'ready')) {
|
||||
usleep(1000);
|
||||
}
|
||||
$process->signal(SIGSTOP);
|
||||
$process->wait();
|
||||
|
||||
return $process->getExitCode();
|
||||
} catch (ProcessTimedOutException $t) {
|
||||
echo $t->getMessage().PHP_EOL;
|
||||
|
||||
return 1;
|
||||
}
|
||||
178
vendor/symfony/process/Tests/ExecutableFinderTest.php
vendored
Normal file
178
vendor/symfony/process/Tests/ExecutableFinderTest.php
vendored
Normal file
@@ -0,0 +1,178 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Process\ExecutableFinder;
|
||||
|
||||
/**
|
||||
* @author Chris Smith <chris@cs278.org>
|
||||
*/
|
||||
class ExecutableFinderTest extends TestCase
|
||||
{
|
||||
private $path;
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
if ($this->path) {
|
||||
// Restore path if it was changed.
|
||||
putenv('PATH='.$this->path);
|
||||
}
|
||||
}
|
||||
|
||||
private function setPath($path)
|
||||
{
|
||||
$this->path = getenv('PATH');
|
||||
putenv('PATH='.$path);
|
||||
}
|
||||
|
||||
public function testFind()
|
||||
{
|
||||
if (ini_get('open_basedir')) {
|
||||
$this->markTestSkipped('Cannot test when open_basedir is set');
|
||||
}
|
||||
|
||||
$this->setPath(\dirname(PHP_BINARY));
|
||||
|
||||
$finder = new ExecutableFinder();
|
||||
$result = $finder->find($this->getPhpBinaryName());
|
||||
|
||||
$this->assertSamePath(PHP_BINARY, $result);
|
||||
}
|
||||
|
||||
public function testFindWithDefault()
|
||||
{
|
||||
if (ini_get('open_basedir')) {
|
||||
$this->markTestSkipped('Cannot test when open_basedir is set');
|
||||
}
|
||||
|
||||
$expected = 'defaultValue';
|
||||
|
||||
$this->setPath('');
|
||||
|
||||
$finder = new ExecutableFinder();
|
||||
$result = $finder->find('foo', $expected);
|
||||
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
public function testFindWithNullAsDefault()
|
||||
{
|
||||
if (ini_get('open_basedir')) {
|
||||
$this->markTestSkipped('Cannot test when open_basedir is set');
|
||||
}
|
||||
|
||||
$this->setPath('');
|
||||
|
||||
$finder = new ExecutableFinder();
|
||||
|
||||
$result = $finder->find('foo');
|
||||
|
||||
$this->assertNull($result);
|
||||
}
|
||||
|
||||
public function testFindWithExtraDirs()
|
||||
{
|
||||
if (ini_get('open_basedir')) {
|
||||
$this->markTestSkipped('Cannot test when open_basedir is set');
|
||||
}
|
||||
|
||||
$this->setPath('');
|
||||
|
||||
$extraDirs = [\dirname(PHP_BINARY)];
|
||||
|
||||
$finder = new ExecutableFinder();
|
||||
$result = $finder->find($this->getPhpBinaryName(), null, $extraDirs);
|
||||
|
||||
$this->assertSamePath(PHP_BINARY, $result);
|
||||
}
|
||||
|
||||
public function testFindWithOpenBaseDir()
|
||||
{
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$this->markTestSkipped('Cannot run test on windows');
|
||||
}
|
||||
|
||||
if (ini_get('open_basedir')) {
|
||||
$this->markTestSkipped('Cannot test when open_basedir is set');
|
||||
}
|
||||
|
||||
$this->iniSet('open_basedir', \dirname(PHP_BINARY).PATH_SEPARATOR.'/');
|
||||
|
||||
$finder = new ExecutableFinder();
|
||||
$result = $finder->find($this->getPhpBinaryName());
|
||||
|
||||
$this->assertSamePath(PHP_BINARY, $result);
|
||||
}
|
||||
|
||||
public function testFindProcessInOpenBasedir()
|
||||
{
|
||||
if (ini_get('open_basedir')) {
|
||||
$this->markTestSkipped('Cannot test when open_basedir is set');
|
||||
}
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$this->markTestSkipped('Cannot run test on windows');
|
||||
}
|
||||
|
||||
$this->setPath('');
|
||||
$this->iniSet('open_basedir', PHP_BINARY.PATH_SEPARATOR.'/');
|
||||
|
||||
$finder = new ExecutableFinder();
|
||||
$result = $finder->find($this->getPhpBinaryName(), false);
|
||||
|
||||
$this->assertSamePath(PHP_BINARY, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 5.4
|
||||
*/
|
||||
public function testFindBatchExecutableOnWindows()
|
||||
{
|
||||
if (ini_get('open_basedir')) {
|
||||
$this->markTestSkipped('Cannot test when open_basedir is set');
|
||||
}
|
||||
if ('\\' !== \DIRECTORY_SEPARATOR) {
|
||||
$this->markTestSkipped('Can be only tested on windows');
|
||||
}
|
||||
|
||||
$target = tempnam(sys_get_temp_dir(), 'example-windows-executable');
|
||||
|
||||
touch($target);
|
||||
touch($target.'.BAT');
|
||||
|
||||
$this->assertFalse(is_executable($target));
|
||||
|
||||
$this->setPath(sys_get_temp_dir());
|
||||
|
||||
$finder = new ExecutableFinder();
|
||||
$result = $finder->find(basename($target), false);
|
||||
|
||||
unlink($target);
|
||||
unlink($target.'.BAT');
|
||||
|
||||
$this->assertSamePath($target.'.BAT', $result);
|
||||
}
|
||||
|
||||
private function assertSamePath($expected, $tested)
|
||||
{
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$this->assertEquals(strtolower($expected), strtolower($tested));
|
||||
} else {
|
||||
$this->assertEquals($expected, $tested);
|
||||
}
|
||||
}
|
||||
|
||||
private function getPhpBinaryName()
|
||||
{
|
||||
return basename(PHP_BINARY, '\\' === \DIRECTORY_SEPARATOR ? '.exe' : '');
|
||||
}
|
||||
}
|
||||
25
vendor/symfony/process/Tests/KillableProcessWithOutput.php
vendored
Normal file
25
vendor/symfony/process/Tests/KillableProcessWithOutput.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
$outputs = [
|
||||
'First iteration output',
|
||||
'Second iteration output',
|
||||
'One more iteration output',
|
||||
'This took more time',
|
||||
];
|
||||
|
||||
$iterationTime = 10000;
|
||||
|
||||
foreach ($outputs as $output) {
|
||||
usleep($iterationTime);
|
||||
$iterationTime *= 10;
|
||||
echo $output."\n";
|
||||
}
|
||||
47
vendor/symfony/process/Tests/NonStopableProcess.php
vendored
Normal file
47
vendor/symfony/process/Tests/NonStopableProcess.php
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Runs a PHP script that can be stopped only with a SIGKILL (9) signal for 3 seconds.
|
||||
*
|
||||
* @args duration Run this script with a custom duration
|
||||
*
|
||||
* @example `php NonStopableProcess.php 42` will run the script for 42 seconds
|
||||
*/
|
||||
function handleSignal($signal)
|
||||
{
|
||||
switch ($signal) {
|
||||
case SIGTERM:
|
||||
$name = 'SIGTERM';
|
||||
break;
|
||||
case SIGINT:
|
||||
$name = 'SIGINT';
|
||||
break;
|
||||
default:
|
||||
$name = $signal.' (unknown)';
|
||||
break;
|
||||
}
|
||||
|
||||
echo "signal $name\n";
|
||||
}
|
||||
|
||||
pcntl_signal(SIGTERM, 'handleSignal');
|
||||
pcntl_signal(SIGINT, 'handleSignal');
|
||||
|
||||
echo 'received ';
|
||||
|
||||
$duration = isset($argv[1]) ? (int) $argv[1] : 3;
|
||||
$start = microtime(true);
|
||||
|
||||
while ($duration > (microtime(true) - $start)) {
|
||||
usleep(10000);
|
||||
pcntl_signal_dispatch();
|
||||
}
|
||||
49
vendor/symfony/process/Tests/PhpExecutableFinderTest.php
vendored
Normal file
49
vendor/symfony/process/Tests/PhpExecutableFinderTest.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Process\PhpExecutableFinder;
|
||||
|
||||
/**
|
||||
* @author Robert Schönthal <seroscho@googlemail.com>
|
||||
*/
|
||||
class PhpExecutableFinderTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* tests find() with the constant PHP_BINARY.
|
||||
*/
|
||||
public function testFind()
|
||||
{
|
||||
$f = new PhpExecutableFinder();
|
||||
|
||||
$current = PHP_BINARY;
|
||||
$args = 'phpdbg' === \PHP_SAPI ? ' -qrr' : '';
|
||||
|
||||
$this->assertEquals($current.$args, $f->find(), '::find() returns the executable PHP');
|
||||
$this->assertEquals($current, $f->find(false), '::find() returns the executable PHP');
|
||||
}
|
||||
|
||||
/**
|
||||
* tests find() with the env var PHP_PATH.
|
||||
*/
|
||||
public function testFindArguments()
|
||||
{
|
||||
$f = new PhpExecutableFinder();
|
||||
|
||||
if ('phpdbg' === \PHP_SAPI) {
|
||||
$this->assertEquals($f->findArguments(), ['-qrr'], '::findArguments() returns phpdbg arguments');
|
||||
} else {
|
||||
$this->assertEquals($f->findArguments(), [], '::findArguments() returns no arguments');
|
||||
}
|
||||
}
|
||||
}
|
||||
63
vendor/symfony/process/Tests/PhpProcessTest.php
vendored
Normal file
63
vendor/symfony/process/Tests/PhpProcessTest.php
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Process\PhpExecutableFinder;
|
||||
use Symfony\Component\Process\PhpProcess;
|
||||
|
||||
class PhpProcessTest extends TestCase
|
||||
{
|
||||
public function testNonBlockingWorks()
|
||||
{
|
||||
$expected = 'hello world!';
|
||||
$process = new PhpProcess(<<<PHP
|
||||
<?php echo '$expected';
|
||||
PHP
|
||||
);
|
||||
$process->start();
|
||||
$process->wait();
|
||||
$this->assertEquals($expected, $process->getOutput());
|
||||
}
|
||||
|
||||
public function testCommandLine()
|
||||
{
|
||||
$process = new PhpProcess(<<<'PHP'
|
||||
<?php echo phpversion().PHP_SAPI;
|
||||
PHP
|
||||
);
|
||||
|
||||
$commandLine = $process->getCommandLine();
|
||||
|
||||
$process->start();
|
||||
$this->assertStringContainsString($commandLine, $process->getCommandLine(), '::getCommandLine() returns the command line of PHP after start');
|
||||
|
||||
$process->wait();
|
||||
$this->assertStringContainsString($commandLine, $process->getCommandLine(), '::getCommandLine() returns the command line of PHP after wait');
|
||||
|
||||
$this->assertSame(PHP_VERSION.\PHP_SAPI, $process->getOutput());
|
||||
}
|
||||
|
||||
public function testPassingPhpExplicitly()
|
||||
{
|
||||
$finder = new PhpExecutableFinder();
|
||||
$php = array_merge([$finder->find(false)], $finder->findArguments());
|
||||
|
||||
$expected = 'hello world!';
|
||||
$script = <<<PHP
|
||||
<?php echo '$expected';
|
||||
PHP;
|
||||
$process = new PhpProcess($script, null, null, 60, $php);
|
||||
$process->run();
|
||||
$this->assertEquals($expected, $process->getOutput());
|
||||
}
|
||||
}
|
||||
72
vendor/symfony/process/Tests/PipeStdinInStdoutStdErrStreamSelect.php
vendored
Normal file
72
vendor/symfony/process/Tests/PipeStdinInStdoutStdErrStreamSelect.php
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
define('ERR_SELECT_FAILED', 1);
|
||||
define('ERR_TIMEOUT', 2);
|
||||
define('ERR_READ_FAILED', 3);
|
||||
define('ERR_WRITE_FAILED', 4);
|
||||
|
||||
$read = [STDIN];
|
||||
$write = [STDOUT, STDERR];
|
||||
|
||||
stream_set_blocking(STDIN, 0);
|
||||
stream_set_blocking(STDOUT, 0);
|
||||
stream_set_blocking(STDERR, 0);
|
||||
|
||||
$out = $err = '';
|
||||
while ($read || $write) {
|
||||
$r = $read;
|
||||
$w = $write;
|
||||
$e = null;
|
||||
$n = stream_select($r, $w, $e, 5);
|
||||
|
||||
if (false === $n) {
|
||||
die(ERR_SELECT_FAILED);
|
||||
} elseif ($n < 1) {
|
||||
die(ERR_TIMEOUT);
|
||||
}
|
||||
|
||||
if (in_array(STDOUT, $w) && strlen($out) > 0) {
|
||||
$written = fwrite(STDOUT, (string) $out, 32768);
|
||||
if (false === $written) {
|
||||
die(ERR_WRITE_FAILED);
|
||||
}
|
||||
$out = (string) substr($out, $written);
|
||||
}
|
||||
if (null === $read && '' === $out) {
|
||||
$write = array_diff($write, [STDOUT]);
|
||||
}
|
||||
|
||||
if (in_array(STDERR, $w) && strlen($err) > 0) {
|
||||
$written = fwrite(STDERR, (string) $err, 32768);
|
||||
if (false === $written) {
|
||||
die(ERR_WRITE_FAILED);
|
||||
}
|
||||
$err = (string) substr($err, $written);
|
||||
}
|
||||
if (null === $read && '' === $err) {
|
||||
$write = array_diff($write, [STDERR]);
|
||||
}
|
||||
|
||||
if ($r) {
|
||||
$str = fread(STDIN, 32768);
|
||||
if (false !== $str) {
|
||||
$out .= $str;
|
||||
$err .= $str;
|
||||
}
|
||||
if (false === $str || feof(STDIN)) {
|
||||
$read = null;
|
||||
if (!feof(STDIN)) {
|
||||
die(ERR_READ_FAILED);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
133
vendor/symfony/process/Tests/ProcessFailedExceptionTest.php
vendored
Normal file
133
vendor/symfony/process/Tests/ProcessFailedExceptionTest.php
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Process\Exception\ProcessFailedException;
|
||||
|
||||
/**
|
||||
* @author Sebastian Marek <proofek@gmail.com>
|
||||
*/
|
||||
class ProcessFailedExceptionTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* tests ProcessFailedException throws exception if the process was successful.
|
||||
*/
|
||||
public function testProcessFailedExceptionThrowsException()
|
||||
{
|
||||
$process = $this->getMockBuilder('Symfony\Component\Process\Process')->setMethods(['isSuccessful'])->setConstructorArgs([['php']])->getMock();
|
||||
$process->expects($this->once())
|
||||
->method('isSuccessful')
|
||||
->willReturn(true);
|
||||
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Expected a failed process, but the given process was successful.');
|
||||
|
||||
new ProcessFailedException($process);
|
||||
}
|
||||
|
||||
/**
|
||||
* tests ProcessFailedException uses information from process output
|
||||
* to generate exception message.
|
||||
*/
|
||||
public function testProcessFailedExceptionPopulatesInformationFromProcessOutput()
|
||||
{
|
||||
$cmd = 'php';
|
||||
$exitCode = 1;
|
||||
$exitText = 'General error';
|
||||
$output = 'Command output';
|
||||
$errorOutput = 'FATAL: Unexpected error';
|
||||
$workingDirectory = getcwd();
|
||||
|
||||
$process = $this->getMockBuilder('Symfony\Component\Process\Process')->setMethods(['isSuccessful', 'getOutput', 'getErrorOutput', 'getExitCode', 'getExitCodeText', 'isOutputDisabled', 'getWorkingDirectory'])->setConstructorArgs([[$cmd]])->getMock();
|
||||
$process->expects($this->once())
|
||||
->method('isSuccessful')
|
||||
->willReturn(false);
|
||||
|
||||
$process->expects($this->once())
|
||||
->method('getOutput')
|
||||
->willReturn($output);
|
||||
|
||||
$process->expects($this->once())
|
||||
->method('getErrorOutput')
|
||||
->willReturn($errorOutput);
|
||||
|
||||
$process->expects($this->once())
|
||||
->method('getExitCode')
|
||||
->willReturn($exitCode);
|
||||
|
||||
$process->expects($this->once())
|
||||
->method('getExitCodeText')
|
||||
->willReturn($exitText);
|
||||
|
||||
$process->expects($this->once())
|
||||
->method('isOutputDisabled')
|
||||
->willReturn(false);
|
||||
|
||||
$process->expects($this->once())
|
||||
->method('getWorkingDirectory')
|
||||
->willReturn($workingDirectory);
|
||||
|
||||
$exception = new ProcessFailedException($process);
|
||||
|
||||
$this->assertEquals(
|
||||
"The command \"$cmd\" failed.\n\nExit Code: $exitCode($exitText)\n\nWorking directory: {$workingDirectory}\n\nOutput:\n================\n{$output}\n\nError Output:\n================\n{$errorOutput}",
|
||||
str_replace("'php'", 'php', $exception->getMessage())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that ProcessFailedException does not extract information from
|
||||
* process output if it was previously disabled.
|
||||
*/
|
||||
public function testDisabledOutputInFailedExceptionDoesNotPopulateOutput()
|
||||
{
|
||||
$cmd = 'php';
|
||||
$exitCode = 1;
|
||||
$exitText = 'General error';
|
||||
$workingDirectory = getcwd();
|
||||
|
||||
$process = $this->getMockBuilder('Symfony\Component\Process\Process')->setMethods(['isSuccessful', 'isOutputDisabled', 'getExitCode', 'getExitCodeText', 'getOutput', 'getErrorOutput', 'getWorkingDirectory'])->setConstructorArgs([[$cmd]])->getMock();
|
||||
$process->expects($this->once())
|
||||
->method('isSuccessful')
|
||||
->willReturn(false);
|
||||
|
||||
$process->expects($this->never())
|
||||
->method('getOutput');
|
||||
|
||||
$process->expects($this->never())
|
||||
->method('getErrorOutput');
|
||||
|
||||
$process->expects($this->once())
|
||||
->method('getExitCode')
|
||||
->willReturn($exitCode);
|
||||
|
||||
$process->expects($this->once())
|
||||
->method('getExitCodeText')
|
||||
->willReturn($exitText);
|
||||
|
||||
$process->expects($this->once())
|
||||
->method('isOutputDisabled')
|
||||
->willReturn(true);
|
||||
|
||||
$process->expects($this->once())
|
||||
->method('getWorkingDirectory')
|
||||
->willReturn($workingDirectory);
|
||||
|
||||
$exception = new ProcessFailedException($process);
|
||||
|
||||
$this->assertEquals(
|
||||
"The command \"$cmd\" failed.\n\nExit Code: $exitCode($exitText)\n\nWorking directory: {$workingDirectory}",
|
||||
str_replace("'php'", 'php', $exception->getMessage())
|
||||
);
|
||||
}
|
||||
}
|
||||
1515
vendor/symfony/process/Tests/ProcessTest.php
vendored
Normal file
1515
vendor/symfony/process/Tests/ProcessTest.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
21
vendor/symfony/process/Tests/SignalListener.php
vendored
Normal file
21
vendor/symfony/process/Tests/SignalListener.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
pcntl_signal(SIGUSR1, function () { echo 'SIGUSR1'; exit; });
|
||||
|
||||
echo 'Caught ';
|
||||
|
||||
$n = 0;
|
||||
|
||||
while ($n++ < 400) {
|
||||
usleep(10000);
|
||||
pcntl_signal_dispatch();
|
||||
}
|
||||
33
vendor/symfony/process/composer.json
vendored
Normal file
33
vendor/symfony/process/composer.json
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "symfony/process",
|
||||
"type": "library",
|
||||
"description": "Symfony Process Component",
|
||||
"keywords": [],
|
||||
"homepage": "https://symfony.com",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.1.3"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Symfony\\Component\\Process\\": "" },
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.3-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
30
vendor/symfony/process/phpunit.xml.dist
vendored
Normal file
30
vendor/symfony/process/phpunit.xml.dist
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.2/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
colors="true"
|
||||
bootstrap="vendor/autoload.php"
|
||||
failOnRisky="true"
|
||||
failOnWarning="true"
|
||||
>
|
||||
<php>
|
||||
<ini name="error_reporting" value="-1" />
|
||||
</php>
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="Symfony Process Component Test Suite">
|
||||
<directory>./Tests/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory>./</directory>
|
||||
<exclude>
|
||||
<directory>./Tests</directory>
|
||||
<directory>./vendor</directory>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
Reference in New Issue
Block a user