[Process] Add missing docblocks, remove variable declarations
This commit is contained in:
parent
ba55b1ed18
commit
ff77f24092
@ -52,7 +52,7 @@ class Process
|
|||||||
private $processInformation;
|
private $processInformation;
|
||||||
private $stdout;
|
private $stdout;
|
||||||
private $stderr;
|
private $stderr;
|
||||||
private $enhanceWindowsCompatibility;
|
private $enhanceWindowsCompatibility = true;
|
||||||
private $enhanceSigchildCompatibility;
|
private $enhanceSigchildCompatibility;
|
||||||
private $process;
|
private $process;
|
||||||
private $status = self::STATUS_READY;
|
private $status = self::STATUS_READY;
|
||||||
@ -143,19 +143,16 @@ class Process
|
|||||||
// on Gnu/Linux, PHP builds with --enable-maintainer-zts are also affected
|
// 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=51800
|
||||||
// @see : https://bugs.php.net/bug.php?id=50524
|
// @see : https://bugs.php.net/bug.php?id=50524
|
||||||
|
|
||||||
if (null === $this->cwd && (defined('ZEND_THREAD_SAFE') || defined('PHP_WINDOWS_VERSION_BUILD'))) {
|
if (null === $this->cwd && (defined('ZEND_THREAD_SAFE') || defined('PHP_WINDOWS_VERSION_BUILD'))) {
|
||||||
$this->cwd = getcwd();
|
$this->cwd = getcwd();
|
||||||
}
|
}
|
||||||
if (null !== $env) {
|
if (null !== $env) {
|
||||||
$this->setEnv($env);
|
$this->setEnv($env);
|
||||||
} else {
|
|
||||||
$this->env = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->stdin = $stdin;
|
$this->stdin = $stdin;
|
||||||
$this->setTimeout($timeout);
|
$this->setTimeout($timeout);
|
||||||
$this->useFileHandles = defined('PHP_WINDOWS_VERSION_BUILD');
|
$this->useFileHandles = defined('PHP_WINDOWS_VERSION_BUILD');
|
||||||
$this->enhanceWindowsCompatibility = true;
|
|
||||||
$this->enhanceSigchildCompatibility = !defined('PHP_WINDOWS_VERSION_BUILD') && $this->isSigchildEnabled();
|
$this->enhanceSigchildCompatibility = !defined('PHP_WINDOWS_VERSION_BUILD') && $this->isSigchildEnabled();
|
||||||
$this->options = array_replace(array('suppress_errors' => true, 'binary_pipes' => true), $options);
|
$this->options = array_replace(array('suppress_errors' => true, 'binary_pipes' => true), $options);
|
||||||
}
|
}
|
||||||
@ -1197,7 +1194,7 @@ class Process
|
|||||||
/**
|
/**
|
||||||
* Ensures the process is running or terminated, throws a LogicException if the process has a not started.
|
* Ensures the process is running or terminated, throws a LogicException if the process has a not started.
|
||||||
*
|
*
|
||||||
* @param $functionName The function name that was called.
|
* @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.
|
||||||
*/
|
*/
|
||||||
@ -1211,7 +1208,7 @@ class Process
|
|||||||
/**
|
/**
|
||||||
* Ensures the process is terminated, throws a LogicException if the process has a status different than `terminated`.
|
* Ensures the process is terminated, throws a LogicException if the process has a status different than `terminated`.
|
||||||
*
|
*
|
||||||
* @param $functionName The function name that was called.
|
* @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.
|
||||||
*/
|
*/
|
||||||
|
@ -23,23 +23,30 @@ class ProcessBuilder
|
|||||||
{
|
{
|
||||||
private $arguments;
|
private $arguments;
|
||||||
private $cwd;
|
private $cwd;
|
||||||
private $env;
|
private $env = array();
|
||||||
private $stdin;
|
private $stdin;
|
||||||
private $timeout;
|
private $timeout = 60;
|
||||||
private $options;
|
private $options = array();
|
||||||
private $inheritEnv;
|
private $inheritEnv = true;
|
||||||
private $prefix;
|
private $prefix;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param string[] $arguments An array of arguments
|
||||||
|
*/
|
||||||
public function __construct(array $arguments = array())
|
public function __construct(array $arguments = array())
|
||||||
{
|
{
|
||||||
$this->arguments = $arguments;
|
$this->arguments = $arguments;
|
||||||
|
|
||||||
$this->timeout = 60;
|
|
||||||
$this->options = array();
|
|
||||||
$this->env = array();
|
|
||||||
$this->inheritEnv = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a process builder instance.
|
||||||
|
*
|
||||||
|
* @param string[] $arguments An array of arguments
|
||||||
|
*
|
||||||
|
* @return ProcessBuilder
|
||||||
|
*/
|
||||||
public static function create(array $arguments = array())
|
public static function create(array $arguments = array())
|
||||||
{
|
{
|
||||||
return new static($arguments);
|
return new static($arguments);
|
||||||
@ -62,7 +69,7 @@ class ProcessBuilder
|
|||||||
/**
|
/**
|
||||||
* Adds an unescaped prefix to the command string.
|
* Adds an unescaped prefix to the command string.
|
||||||
*
|
*
|
||||||
* The prefix is preserved when reseting arguments.
|
* The prefix is preserved when resetting arguments.
|
||||||
*
|
*
|
||||||
* @param string $prefix A command prefix
|
* @param string $prefix A command prefix
|
||||||
*
|
*
|
||||||
@ -76,7 +83,12 @@ class ProcessBuilder
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $arguments
|
* Sets the arguments of the process.
|
||||||
|
*
|
||||||
|
* Arguments must not be escaped.
|
||||||
|
* Previous arguments are removed.
|
||||||
|
*
|
||||||
|
* @param string[] $arguments
|
||||||
*
|
*
|
||||||
* @return ProcessBuilder
|
* @return ProcessBuilder
|
||||||
*/
|
*/
|
||||||
@ -87,6 +99,13 @@ class ProcessBuilder
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the working directory.
|
||||||
|
*
|
||||||
|
* @param null|string $cwd The working directory
|
||||||
|
*
|
||||||
|
* @return ProcessBuilder
|
||||||
|
*/
|
||||||
public function setWorkingDirectory($cwd)
|
public function setWorkingDirectory($cwd)
|
||||||
{
|
{
|
||||||
$this->cwd = $cwd;
|
$this->cwd = $cwd;
|
||||||
@ -94,6 +113,13 @@ class ProcessBuilder
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether environment variables will be inherited or not.
|
||||||
|
*
|
||||||
|
* @param bool $inheritEnv
|
||||||
|
*
|
||||||
|
* @return ProcessBuilder
|
||||||
|
*/
|
||||||
public function inheritEnvironmentVariables($inheritEnv = true)
|
public function inheritEnvironmentVariables($inheritEnv = true)
|
||||||
{
|
{
|
||||||
$this->inheritEnv = $inheritEnv;
|
$this->inheritEnv = $inheritEnv;
|
||||||
@ -101,6 +127,17 @@ class ProcessBuilder
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets an environment variable
|
||||||
|
*
|
||||||
|
* Setting a variable overrides its previous value. Use `null` to unset a
|
||||||
|
* defined environment variable.
|
||||||
|
*
|
||||||
|
* @param string $name The variable name
|
||||||
|
* @param null|string $value The variable value
|
||||||
|
*
|
||||||
|
* @return ProcessBuilder
|
||||||
|
*/
|
||||||
public function setEnv($name, $value)
|
public function setEnv($name, $value)
|
||||||
{
|
{
|
||||||
$this->env[$name] = $value;
|
$this->env[$name] = $value;
|
||||||
@ -108,6 +145,13 @@ class ProcessBuilder
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the input of the process.
|
||||||
|
*
|
||||||
|
* @param string $stdin The input as a string
|
||||||
|
*
|
||||||
|
* @return ProcessBuilder
|
||||||
|
*/
|
||||||
public function setInput($stdin)
|
public function setInput($stdin)
|
||||||
{
|
{
|
||||||
$this->stdin = $stdin;
|
$this->stdin = $stdin;
|
||||||
@ -145,6 +189,14 @@ class ProcessBuilder
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a proc_open option.
|
||||||
|
*
|
||||||
|
* @param string $name The option name
|
||||||
|
* @param string $value The option value
|
||||||
|
*
|
||||||
|
* @return ProcessBuilder
|
||||||
|
*/
|
||||||
public function setOption($name, $value)
|
public function setOption($name, $value)
|
||||||
{
|
{
|
||||||
$this->options[$name] = $value;
|
$this->options[$name] = $value;
|
||||||
@ -152,6 +204,13 @@ class ProcessBuilder
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a Process instance and returns it.
|
||||||
|
*
|
||||||
|
* @return Process
|
||||||
|
*
|
||||||
|
* @throws LogicException In case no arguments have been provided
|
||||||
|
*/
|
||||||
public function getProcess()
|
public function getProcess()
|
||||||
{
|
{
|
||||||
if (!$this->prefix && !count($this->arguments)) {
|
if (!$this->prefix && !count($this->arguments)) {
|
||||||
|
Reference in New Issue
Block a user