diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 99374fef3a..9f6a24933f 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -55,7 +55,7 @@ class Process private $processInformation; private $stdout; private $stderr; - private $enhanceWindowsCompatibility; + private $enhanceWindowsCompatibility = true; private $enhanceSigchildCompatibility; private $process; private $status = self::STATUS_READY; @@ -146,19 +146,16 @@ class Process // 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') || defined('PHP_WINDOWS_VERSION_BUILD'))) { $this->cwd = getcwd(); } if (null !== $env) { $this->setEnv($env); - } else { - $this->env = null; } + $this->stdin = $stdin; $this->setTimeout($timeout); $this->useFileHandles = defined('PHP_WINDOWS_VERSION_BUILD'); - $this->enhanceWindowsCompatibility = true; $this->enhanceSigchildCompatibility = !defined('PHP_WINDOWS_VERSION_BUILD') && $this->isSigchildEnabled(); $this->options = array_replace(array('suppress_errors' => true, 'binary_pipes' => true), $options); } @@ -1282,7 +1279,7 @@ class Process /** * 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. */ @@ -1296,7 +1293,7 @@ class Process /** * 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. */ diff --git a/src/Symfony/Component/Process/ProcessBuilder.php b/src/Symfony/Component/Process/ProcessBuilder.php index b6168feb62..c9a77d4482 100644 --- a/src/Symfony/Component/Process/ProcessBuilder.php +++ b/src/Symfony/Component/Process/ProcessBuilder.php @@ -30,11 +30,23 @@ class ProcessBuilder private $inheritEnv = true; private $prefix = array(); + /** + * Constructor + * + * @param string[] $arguments An array of arguments + */ public function __construct(array $arguments = array()) { $this->arguments = $arguments; } + /** + * Creates a process builder instance. + * + * @param string[] $arguments An array of arguments + * + * @return ProcessBuilder + */ public static function create(array $arguments = array()) { return new static($arguments); @@ -71,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 */ @@ -82,6 +99,13 @@ class ProcessBuilder return $this; } + /** + * Sets the working directory. + * + * @param null|string $cwd The working directory + * + * @return ProcessBuilder + */ public function setWorkingDirectory($cwd) { $this->cwd = $cwd; @@ -89,6 +113,13 @@ class ProcessBuilder return $this; } + /** + * Sets whether environment variables will be inherited or not. + * + * @param bool $inheritEnv + * + * @return ProcessBuilder + */ public function inheritEnvironmentVariables($inheritEnv = true) { $this->inheritEnv = $inheritEnv; @@ -96,6 +127,17 @@ class ProcessBuilder 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) { $this->env[$name] = $value; @@ -110,6 +152,13 @@ class ProcessBuilder return $this; } + /** + * Sets the input of the process. + * + * @param string $stdin The input as a string + * + * @return ProcessBuilder + */ public function setInput($stdin) { $this->stdin = $stdin; @@ -147,6 +196,14 @@ class ProcessBuilder 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) { $this->options[$name] = $value; @@ -154,6 +211,13 @@ class ProcessBuilder return $this; } + /** + * Creates a Process instance and returns it. + * + * @return Process + * + * @throws LogicException In case no arguments have been provided + */ public function getProcess() { if (0 === count($this->prefix) && 0 === count($this->arguments)) {