Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[2.3][Process] Add missing docblocks, remove variable declarations #10756

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions src/Symfony/Component/Process/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Process
private $processInformation;
private $stdout;
private $stderr;
private $enhanceWindowsCompatibility;
private $enhanceWindowsCompatibility = true;
private $enhanceSigchildCompatibility;
private $process;
private $status = self::STATUS_READY;
Expand Down Expand Up @@ -143,19 +143,16 @@ public function __construct($commandline, $cwd = null, array $env = null, $stdin
// 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);
}
Expand Down Expand Up @@ -1197,7 +1194,7 @@ private function doSignal($signal, $throwException)
/**
* 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.
*/
Expand All @@ -1211,7 +1208,7 @@ private function requireProcessIsStarted($functionName)
/**
* 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.
*/
Expand Down
81 changes: 70 additions & 11 deletions src/Symfony/Component/Process/ProcessBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,30 @@ class ProcessBuilder
{
private $arguments;
private $cwd;
private $env;
private $env = array();
private $stdin;
private $timeout;
private $options;
private $inheritEnv;
private $timeout = 60;
private $options = array();
private $inheritEnv = true;
private $prefix;

/**
* Constructor
*
* @param string[] $arguments An array of arguments
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is right for the default values of the ProcessBuilder, not for the Process
Docblocks are still missing in version 2.4

Merging in 2.4 should be easy

public function __construct(array $arguments = array())
{
$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())
{
return new static($arguments);
Expand All @@ -62,7 +69,7 @@ public function add($argument)
/**
* 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
*
Expand All @@ -76,7 +83,12 @@ public function setPrefix($prefix)
}

/**
* @param array $arguments
* Sets the arguments of the process.
*
* Arguments must not be escaped.
* Previous arguments are removed.
*
* @param string[] $arguments
*
* @return ProcessBuilder
*/
Expand All @@ -87,27 +99,59 @@ public function setArguments(array $arguments)
return $this;
}

/**
* Sets the working directory.
*
* @param null|string $cwd The working directory
*
* @return ProcessBuilder
*/
public function setWorkingDirectory($cwd)
{
$this->cwd = $cwd;

return $this;
}

/**
* Sets whether environment variables will be inherited or not.
*
* @param bool $inheritEnv
*
* @return ProcessBuilder
*/
public function inheritEnvironmentVariables($inheritEnv = true)
{
$this->inheritEnv = $inheritEnv;

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;

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;
Expand Down Expand Up @@ -145,13 +189,28 @@ public function setTimeout($timeout)
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;

return $this;
}

/**
* Creates a Process instance and returns it.
*
* @return Process
*
* @throws LogicException In case no arguments have been provided
*/
public function getProcess()
{
if (!$this->prefix && !count($this->arguments)) {
Expand Down