Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 19ff37a

Browse filesBrowse files
committed
[Process] remove deprecated features
1 parent 4d3c74b commit 19ff37a
Copy full SHA for 19ff37a

File tree

8 files changed

+29
-361
lines changed
Filter options

8 files changed

+29
-361
lines changed

‎src/Symfony/Component/Process/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Process/CHANGELOG.md
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
CHANGELOG
22
=========
33

4+
4.0.0
5+
-----
6+
7+
* support for passing `proc_open()` options has been removed
8+
* added a second `array $env = array()` argument to the `start()` method of
9+
the `Process` class
10+
* the `areEnvironmentVariablesInherited()`, `getOptions()`, `setOptions()`,
11+
`getEnhanceWindowsCompatibility()`, `getEnhanceSigchildCompatibility()`,
12+
`setEnhanceSigchildCompatibility()`, and `setEnhanceWindowsCompatibility()`
13+
methods of the `Process` class have been removed
14+
* environment variables will always be inherited
15+
* the `ProcessUtils::escapeArgument()` method has been removed
16+
* the `inheritEnvironmentVariables()` and `setOption()` options of the
17+
`ProcessBuilder` class have been removed
18+
419
3.3.0
520
-----
621

‎src/Symfony/Component/Process/PhpProcess.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Process/PhpProcess.php
+3-8Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ class PhpProcess extends Process
3131
* @param string|null $cwd The working directory or null to use the working dir of the current PHP process
3232
* @param array|null $env The environment variables or null to use the same environment as the current PHP process
3333
* @param int $timeout The timeout in seconds
34-
* @param array $options An array of options for proc_open
3534
*/
36-
public function __construct($script, $cwd = null, array $env = null, $timeout = 60, array $options = null)
35+
public function __construct($script, $cwd = null, array $env = null, $timeout = 60)
3736
{
3837
$executableFinder = new PhpExecutableFinder();
3938
if (false === $php = $executableFinder->find(false)) {
@@ -48,11 +47,8 @@ public function __construct($script, $cwd = null, array $env = null, $timeout =
4847
$php[] = $file;
4948
$script = null;
5049
}
51-
if (null !== $options) {
52-
@trigger_error(sprintf('The $options parameter of the %s constructor is deprecated since version 3.3 and will be removed in 4.0.', __CLASS__), E_USER_DEPRECATED);
53-
}
5450

55-
parent::__construct($php, $cwd, $env, $script, $timeout, $options);
51+
parent::__construct($php, $cwd, $env, $script, $timeout);
5652
}
5753

5854
/**
@@ -66,12 +62,11 @@ public function setPhpBinary($php)
6662
/**
6763
* {@inheritdoc}
6864
*/
69-
public function start(callable $callback = null/*, array $env = array()*/)
65+
public function start(callable $callback = null, array $env = array())
7066
{
7167
if (null === $this->getCommandLine()) {
7268
throw new RuntimeException('Unable to find the PHP executable.');
7369
}
74-
$env = 1 < func_num_args() ? func_get_arg(1) : null;
7570

7671
parent::start($callback, $env);
7772
}

‎src/Symfony/Component/Process/Process.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Process/Process.php
+11-156Lines changed: 11 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ class Process implements \IteratorAggregate
7373
private $incrementalErrorOutputOffset = 0;
7474
private $tty;
7575
private $pty;
76-
private $inheritEnv = false;
7776

7877
private $useFileHandles = false;
7978
/** @var PipesInterface */
@@ -141,11 +140,10 @@ class Process implements \IteratorAggregate
141140
* @param array|null $env The environment variables or null to use the same environment as the current PHP process
142141
* @param mixed|null $input The input as stream resource, scalar or \Traversable, or null for no input
143142
* @param int|float|null $timeout The timeout in seconds or null to disable
144-
* @param array $options An array of options for proc_open
145143
*
146144
* @throws RuntimeException When proc_open is not installed
147145
*/
148-
public function __construct($commandline, $cwd = null, array $env = null, $input = null, $timeout = 60, array $options = null)
146+
public function __construct($commandline, $cwd = null, array $env = null, $input = null, $timeout = 60)
149147
{
150148
if (!function_exists('proc_open')) {
151149
throw new RuntimeException('The Process class relies on proc_open, which is not available on your PHP installation.');
@@ -169,11 +167,6 @@ public function __construct($commandline, $cwd = null, array $env = null, $input
169167
$this->setTimeout($timeout);
170168
$this->useFileHandles = '\\' === DIRECTORY_SEPARATOR;
171169
$this->pty = false;
172-
$this->enhanceSigchildCompatibility = '\\' !== DIRECTORY_SEPARATOR && $this->isSigchildEnabled();
173-
if (null !== $options) {
174-
@trigger_error(sprintf('The $options parameter of the %s constructor is deprecated since version 3.3 and will be removed in 4.0.', __CLASS__), E_USER_DEPRECATED);
175-
$this->options = array_replace($this->options, $options);
176-
}
177170
}
178171

179172
public function __destruct()
@@ -208,9 +201,8 @@ public function __clone()
208201
*
209202
* @final since version 3.3
210203
*/
211-
public function run($callback = null/*, array $env = array()*/)
204+
public function run($callback = null, array $env = array())
212205
{
213-
$env = 1 < func_num_args() ? func_get_arg(1) : null;
214206
$this->start($callback, $env);
215207

216208
return $this->wait();
@@ -232,12 +224,11 @@ public function run($callback = null/*, array $env = array()*/)
232224
*
233225
* @final since version 3.3
234226
*/
235-
public function mustRun(callable $callback = null/*, array $env = array()*/)
227+
public function mustRun(callable $callback = null, array $env = array())
236228
{
237229
if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
238230
throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.');
239231
}
240-
$env = 1 < func_num_args() ? func_get_arg(1) : null;
241232

242233
if (0 !== $this->run($callback, $env)) {
243234
throw new ProcessFailedException($this);
@@ -266,29 +257,17 @@ public function mustRun(callable $callback = null/*, array $env = array()*/)
266257
* @throws RuntimeException When process is already running
267258
* @throws LogicException In case a callback is provided and output has been disabled
268259
*/
269-
public function start(callable $callback = null/*, array $env = array()*/)
260+
public function start(callable $callback = null, array $env = array())
270261
{
271262
if ($this->isRunning()) {
272263
throw new RuntimeException('Process is already running');
273264
}
274-
if (2 <= func_num_args()) {
275-
$env = func_get_arg(1);
276-
} else {
277-
if (__CLASS__ !== static::class) {
278-
$r = new \ReflectionMethod($this, __FUNCTION__);
279-
if (__CLASS__ !== $r->getDeclaringClass()->getName() && (2 > $r->getNumberOfParameters() || 'env' !== $r->getParameters()[0]->name)) {
280-
@trigger_error(sprintf('The %s::start() method expects a second "$env" argument since version 3.3. It will be made mandatory in 4.0.', static::class), E_USER_DEPRECATED);
281-
}
282-
}
283-
$env = null;
284-
}
285265

286266
$this->resetProcessData();
287267
$this->starttime = $this->lastOutputTime = microtime(true);
288268
$this->callback = $this->buildCallback($callback);
289269
$this->hasCallback = null !== $callback;
290270
$descriptors = $this->getDescriptors();
291-
$inheritEnv = $this->inheritEnv;
292271

293272
if (is_array($commandline = $this->commandline)) {
294273
$commandline = implode(' ', array_map(array($this, 'escapeArgument'), $commandline));
@@ -301,22 +280,17 @@ public function start(callable $callback = null/*, array $env = array()*/)
301280

302281
if (null === $env) {
303282
$env = $this->env;
304-
} else {
305-
if ($this->env) {
306-
$env += $this->env;
307-
}
308-
$inheritEnv = true;
283+
} elseif ($this->env) {
284+
$env += $this->env;
309285
}
310286

311287
$envBackup = array();
312-
if (null !== $env && $inheritEnv) {
288+
if (null !== $env) {
313289
foreach ($env as $k => $v) {
314290
$envBackup[$k] = getenv($k);
315291
putenv(false === $v || null === $v ? $k : "$k=$v");
316292
}
317293
$env = null;
318-
} elseif (null !== $env) {
319-
@trigger_error('Not inheriting environment variables is deprecated since Symfony 3.3 and will always happen in 4.0. Set "Process::inheritEnvironmentVariables()" to true instead.', E_USER_DEPRECATED);
320294
}
321295
if ('\\' === DIRECTORY_SEPARATOR && $this->enhanceWindowsCompatibility) {
322296
$this->options['bypass_shell'] = true;
@@ -375,12 +349,11 @@ public function start(callable $callback = null/*, array $env = array()*/)
375349
*
376350
* @final since version 3.3
377351
*/
378-
public function restart(callable $callback = null/*, array $env = array()*/)
352+
public function restart(callable $callback = null, array $env = array())
379353
{
380354
if ($this->isRunning()) {
381355
throw new RuntimeException('Process is already running');
382356
}
383-
$env = 1 < func_num_args() ? func_get_arg(1) : null;
384357

385358
$process = clone $this;
386359
$process->start($callback, $env);
@@ -1178,108 +1151,6 @@ public function setInput($input)
11781151
return $this;
11791152
}
11801153

1181-
/**
1182-
* Gets the options for proc_open.
1183-
*
1184-
* @return array The current options
1185-
*
1186-
* @deprecated since version 3.3, to be removed in 4.0.
1187-
*/
1188-
public function getOptions()
1189-
{
1190-
@trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED);
1191-
1192-
return $this->options;
1193-
}
1194-
1195-
/**
1196-
* Sets the options for proc_open.
1197-
*
1198-
* @param array $options The new options
1199-
*
1200-
* @return self The current Process instance
1201-
*
1202-
* @deprecated since version 3.3, to be removed in 4.0.
1203-
*/
1204-
public function setOptions(array $options)
1205-
{
1206-
@trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED);
1207-
1208-
$this->options = $options;
1209-
1210-
return $this;
1211-
}
1212-
1213-
/**
1214-
* Gets whether or not Windows compatibility is enabled.
1215-
*
1216-
* This is true by default.
1217-
*
1218-
* @return bool
1219-
*
1220-
* @deprecated since version 3.3, to be removed in 4.0. Enhanced Windows compatibility will always be enabled.
1221-
*/
1222-
public function getEnhanceWindowsCompatibility()
1223-
{
1224-
@trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Enhanced Windows compatibility will always be enabled.', __METHOD__), E_USER_DEPRECATED);
1225-
1226-
return $this->enhanceWindowsCompatibility;
1227-
}
1228-
1229-
/**
1230-
* Sets whether or not Windows compatibility is enabled.
1231-
*
1232-
* @param bool $enhance
1233-
*
1234-
* @return self The current Process instance
1235-
*
1236-
* @deprecated since version 3.3, to be removed in 4.0. Enhanced Windows compatibility will always be enabled.
1237-
*/
1238-
public function setEnhanceWindowsCompatibility($enhance)
1239-
{
1240-
@trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Enhanced Windows compatibility will always be enabled.', __METHOD__), E_USER_DEPRECATED);
1241-
1242-
$this->enhanceWindowsCompatibility = (bool) $enhance;
1243-
1244-
return $this;
1245-
}
1246-
1247-
/**
1248-
* Returns whether sigchild compatibility mode is activated or not.
1249-
*
1250-
* @return bool
1251-
*
1252-
* @deprecated since version 3.3, to be removed in 4.0. Sigchild compatibility will always be enabled.
1253-
*/
1254-
public function getEnhanceSigchildCompatibility()
1255-
{
1256-
@trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Sigchild compatibility will always be enabled.', __METHOD__), E_USER_DEPRECATED);
1257-
1258-
return $this->enhanceSigchildCompatibility;
1259-
}
1260-
1261-
/**
1262-
* Activates sigchild compatibility mode.
1263-
*
1264-
* Sigchild compatibility mode is required to get the exit code and
1265-
* determine the success of a process when PHP has been compiled with
1266-
* the --enable-sigchild option
1267-
*
1268-
* @param bool $enhance
1269-
*
1270-
* @return self The current Process instance
1271-
*
1272-
* @deprecated since version 3.3, to be removed in 4.0.
1273-
*/
1274-
public function setEnhanceSigchildCompatibility($enhance)
1275-
{
1276-
@trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Sigchild compatibility will always be enabled.', __METHOD__), E_USER_DEPRECATED);
1277-
1278-
$this->enhanceSigchildCompatibility = (bool) $enhance;
1279-
1280-
return $this;
1281-
}
1282-
12831154
/**
12841155
* Sets whether environment variables will be inherited or not.
12851156
*
@@ -1290,28 +1161,12 @@ public function setEnhanceSigchildCompatibility($enhance)
12901161
public function inheritEnvironmentVariables($inheritEnv = true)
12911162
{
12921163
if (!$inheritEnv) {
1293-
@trigger_error('Not inheriting environment variables is deprecated since Symfony 3.3 and will always happen in 4.0. Set "Process::inheritEnvironmentVariables()" to true instead.', E_USER_DEPRECATED);
1164+
throw new InvalidArgumentException('Not inheriting environment variables is not supported.');
12941165
}
12951166

1296-
$this->inheritEnv = (bool) $inheritEnv;
1297-
12981167
return $this;
12991168
}
13001169

1301-
/**
1302-
* Returns whether environment variables will be inherited or not.
1303-
*
1304-
* @return bool
1305-
*
1306-
* @deprecated since version 3.3, to be removed in 4.0. Environment variables will always be inherited.
1307-
*/
1308-
public function areEnvironmentVariablesInherited()
1309-
{
1310-
@trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Environment variables will always be inherited.', __METHOD__), E_USER_DEPRECATED);
1311-
1312-
return $this->inheritEnv;
1313-
}
1314-
13151170
/**
13161171
* Performs a check between the timeout definition and the time the process started.
13171172
*
@@ -1429,7 +1284,7 @@ protected function updateStatus($blocking)
14291284

14301285
$this->readPipes($running && $blocking, '\\' !== DIRECTORY_SEPARATOR || !$running);
14311286

1432-
if ($this->fallbackStatus && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
1287+
if ($this->fallbackStatus) {
14331288
$this->processInformation = $this->fallbackStatus + $this->processInformation;
14341289
}
14351290

@@ -1538,7 +1393,7 @@ private function close()
15381393
if ($this->processInformation['signaled'] && 0 < $this->processInformation['termsig']) {
15391394
// if process has been signaled, no exitcode but a valid termsig, apply Unix convention
15401395
$this->exitcode = 128 + $this->processInformation['termsig'];
1541-
} elseif ($this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
1396+
} else {
15421397
$this->processInformation['signaled'] = true;
15431398
$this->processInformation['termsig'] = -1;
15441399
}

‎src/Symfony/Component/Process/ProcessBuilder.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Process/ProcessBuilder.php
-37Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -114,24 +114,6 @@ public function setWorkingDirectory($cwd)
114114
return $this;
115115
}
116116

117-
/**
118-
* Sets whether environment variables will be inherited or not.
119-
*
120-
* @param bool $inheritEnv
121-
*
122-
* @return $this
123-
*
124-
* @deprecated since version 3.3, to be removed in 4.0.
125-
*/
126-
public function inheritEnvironmentVariables($inheritEnv = true)
127-
{
128-
@trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED);
129-
130-
$this->inheritEnv = $inheritEnv;
131-
132-
return $this;
133-
}
134-
135117
/**
136118
* Sets an environment variable.
137119
*
@@ -214,25 +196,6 @@ public function setTimeout($timeout)
214196
return $this;
215197
}
216198

217-
/**
218-
* Adds a proc_open option.
219-
*
220-
* @param string $name The option name
221-
* @param string $value The option value
222-
*
223-
* @return $this
224-
*
225-
* @deprecated since version 3.3, to be removed in 4.0.
226-
*/
227-
public function setOption($name, $value)
228-
{
229-
@trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED);
230-
231-
$this->options[$name] = $value;
232-
233-
return $this;
234-
}
235-
236199
/**
237200
* Disables fetching output and error output from the underlying process.
238201
*

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.