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

Skip to content

Commit 5947eec

Browse files
committed
minor #10756 [2.3][Process] Add missing docblocks, remove variable declarations (romainneutron)
This PR was merged into the 2.3 branch. Discussion ---------- [2.3][Process] Add missing docblocks, remove variable declarations | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT Commits ------- ff77f24 [Process] Add missing docblocks, remove variable declarations
2 parents 1ad7d05 + ff77f24 commit 5947eec

File tree

2 files changed

+74
-18
lines changed

2 files changed

+74
-18
lines changed

src/Symfony/Component/Process/Process.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Process
5252
private $processInformation;
5353
private $stdout;
5454
private $stderr;
55-
private $enhanceWindowsCompatibility;
55+
private $enhanceWindowsCompatibility = true;
5656
private $enhanceSigchildCompatibility;
5757
private $process;
5858
private $status = self::STATUS_READY;
@@ -143,19 +143,16 @@ public function __construct($commandline, $cwd = null, array $env = null, $stdin
143143
// on Gnu/Linux, PHP builds with --enable-maintainer-zts are also affected
144144
// @see : https://bugs.php.net/bug.php?id=51800
145145
// @see : https://bugs.php.net/bug.php?id=50524
146-
147146
if (null === $this->cwd && (defined('ZEND_THREAD_SAFE') || defined('PHP_WINDOWS_VERSION_BUILD'))) {
148147
$this->cwd = getcwd();
149148
}
150149
if (null !== $env) {
151150
$this->setEnv($env);
152-
} else {
153-
$this->env = null;
154151
}
152+
155153
$this->stdin = $stdin;
156154
$this->setTimeout($timeout);
157155
$this->useFileHandles = defined('PHP_WINDOWS_VERSION_BUILD');
158-
$this->enhanceWindowsCompatibility = true;
159156
$this->enhanceSigchildCompatibility = !defined('PHP_WINDOWS_VERSION_BUILD') && $this->isSigchildEnabled();
160157
$this->options = array_replace(array('suppress_errors' => true, 'binary_pipes' => true), $options);
161158
}
@@ -1203,7 +1200,7 @@ private function doSignal($signal, $throwException)
12031200
/**
12041201
* Ensures the process is running or terminated, throws a LogicException if the process has a not started.
12051202
*
1206-
* @param $functionName The function name that was called.
1203+
* @param string $functionName The function name that was called.
12071204
*
12081205
* @throws LogicException If the process has not run.
12091206
*/
@@ -1217,7 +1214,7 @@ private function requireProcessIsStarted($functionName)
12171214
/**
12181215
* Ensures the process is terminated, throws a LogicException if the process has a status different than `terminated`.
12191216
*
1220-
* @param $functionName The function name that was called.
1217+
* @param string $functionName The function name that was called.
12211218
*
12221219
* @throws LogicException If the process is not yet terminated.
12231220
*/

src/Symfony/Component/Process/ProcessBuilder.php

Lines changed: 70 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,30 @@ class ProcessBuilder
2323
{
2424
private $arguments;
2525
private $cwd;
26-
private $env;
26+
private $env = array();
2727
private $stdin;
28-
private $timeout;
29-
private $options;
30-
private $inheritEnv;
28+
private $timeout = 60;
29+
private $options = array();
30+
private $inheritEnv = true;
3131
private $prefix;
3232

33+
/**
34+
* Constructor
35+
*
36+
* @param string[] $arguments An array of arguments
37+
*/
3338
public function __construct(array $arguments = array())
3439
{
3540
$this->arguments = $arguments;
36-
37-
$this->timeout = 60;
38-
$this->options = array();
39-
$this->env = array();
40-
$this->inheritEnv = true;
4141
}
4242

43+
/**
44+
* Creates a process builder instance.
45+
*
46+
* @param string[] $arguments An array of arguments
47+
*
48+
* @return ProcessBuilder
49+
*/
4350
public static function create(array $arguments = array())
4451
{
4552
return new static($arguments);
@@ -62,7 +69,7 @@ public function add($argument)
6269
/**
6370
* Adds an unescaped prefix to the command string.
6471
*
65-
* The prefix is preserved when reseting arguments.
72+
* The prefix is preserved when resetting arguments.
6673
*
6774
* @param string $prefix A command prefix
6875
*
@@ -76,7 +83,12 @@ public function setPrefix($prefix)
7683
}
7784

7885
/**
79-
* @param array $arguments
86+
* Sets the arguments of the process.
87+
*
88+
* Arguments must not be escaped.
89+
* Previous arguments are removed.
90+
*
91+
* @param string[] $arguments
8092
*
8193
* @return ProcessBuilder
8294
*/
@@ -87,27 +99,59 @@ public function setArguments(array $arguments)
8799
return $this;
88100
}
89101

102+
/**
103+
* Sets the working directory.
104+
*
105+
* @param null|string $cwd The working directory
106+
*
107+
* @return ProcessBuilder
108+
*/
90109
public function setWorkingDirectory($cwd)
91110
{
92111
$this->cwd = $cwd;
93112

94113
return $this;
95114
}
96115

116+
/**
117+
* Sets whether environment variables will be inherited or not.
118+
*
119+
* @param bool $inheritEnv
120+
*
121+
* @return ProcessBuilder
122+
*/
97123
public function inheritEnvironmentVariables($inheritEnv = true)
98124
{
99125
$this->inheritEnv = $inheritEnv;
100126

101127
return $this;
102128
}
103129

130+
/**
131+
* Sets an environment variable
132+
*
133+
* Setting a variable overrides its previous value. Use `null` to unset a
134+
* defined environment variable.
135+
*
136+
* @param string $name The variable name
137+
* @param null|string $value The variable value
138+
*
139+
* @return ProcessBuilder
140+
*/
104141
public function setEnv($name, $value)
105142
{
106143
$this->env[$name] = $value;
107144

108145
return $this;
109146
}
110147

148+
/**
149+
* Sets the input of the process.
150+
*
151+
* @param string $stdin The input as a string
152+
*
153+
* @return ProcessBuilder
154+
*/
111155
public function setInput($stdin)
112156
{
113157
$this->stdin = $stdin;
@@ -145,13 +189,28 @@ public function setTimeout($timeout)
145189
return $this;
146190
}
147191

192+
/**
193+
* Adds a proc_open option.
194+
*
195+
* @param string $name The option name
196+
* @param string $value The option value
197+
*
198+
* @return ProcessBuilder
199+
*/
148200
public function setOption($name, $value)
149201
{
150202
$this->options[$name] = $value;
151203

152204
return $this;
153205
}
154206

207+
/**
208+
* Creates a Process instance and returns it.
209+
*
210+
* @return Process
211+
*
212+
* @throws LogicException In case no arguments have been provided
213+
*/
155214
public function getProcess()
156215
{
157216
if (!$this->prefix && !count($this->arguments)) {

0 commit comments

Comments
 (0)