Permalink
Browse files

feature #23111 [Process] Deprecate ProcessBuilder (nicolas-grekas)

This PR was merged into the 3.4 branch.

Discussion
----------

[Process] Deprecate ProcessBuilder

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Commits
-------

3aa8861 [Process] Deprecate ProcessBuilder
  • Loading branch information...
fabpot committed Jun 9, 2017
2 parents e4e1b81 + 3aa8861 commit 1195c7d97ec65b06193da7f9c7583ff036f449c8
View
@@ -26,6 +26,12 @@ FrameworkBundle
* The `KernelTestCase::getPhpUnitXmlDir()` and `KernelTestCase::getPhpUnitCliConfigArgument()`
methods are deprecated since 3.4 and will be removed in 4.0.
Process
-------
* The `Symfony\Component\Process\ProcessBuilder` class has been deprecated,
use the `Symfony\Component\Process\Process` class directly instead.
Validator
---------
View
@@ -420,6 +420,9 @@ Ldap
Process
-------
* The `Symfony\Component\Process\ProcessBuilder` class has been removed,
use the `Symfony\Component\Process\Process` class directly instead.
* The `ProcessUtils::escapeArgument()` method has been removed, use a command line array or give env vars to the `Process::start/run()` method instead.
* Environment variables are always inherited in sub-processes.
@@ -13,7 +13,6 @@
use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\ProcessBuilder;
use Symfony\Component\Process\Exception\RuntimeException;
/**
@@ -151,11 +150,11 @@ private function createServerProcess(WebServerConfig $config)
throw new \RuntimeException('Unable to find the PHP binary.');
}
$builder = new ProcessBuilder(array($binary, '-S', $config->getAddress(), $config->getRouter()));
$builder->setWorkingDirectory($config->getDocumentRoot());
$builder->setTimeout(null);
$process = new Process(array($binary, '-S', $config->getAddress(), $config->getRouter()));
$process->setWorkingDirectory($config->getDocumentRoot());
$process->setTimeout(null);
return $builder->getProcess();
return $process;
}
private function getDefaultPidFile()
@@ -19,7 +19,7 @@
"php": ">=5.5.9",
"symfony/console": "~2.8.8|~3.0.8|~3.1.2|~3.2|~4.0",
"symfony/http-kernel": "~3.3|~4.0",
"symfony/process": "~2.8|~3.0|~4.0"
"symfony/process": "~3.3|~4.0"
},
"autoload": {
"psr-4": { "Symfony\\Bundle\\WebServerBundle\\": "" },
@@ -15,7 +15,6 @@
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\ProcessBuilder;
/**
* The ProcessHelper class provides helpers to run external processes.
@@ -45,7 +44,7 @@ public function run(OutputInterface $output, $cmd, $error = null, callable $call
$formatter = $this->getHelperSet()->get('debug_formatter');
if (is_array($cmd)) {
$process = ProcessBuilder::create($cmd)->getProcess();
$process = new Process($cmd);
} elseif ($cmd instanceof Process) {
$process = $cmd;
} else {
@@ -17,7 +17,6 @@
use Symfony\Component\Console\Output\StreamOutput;
use Symfony\Component\Console\Helper\ProcessHelper;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\ProcessBuilder;
class ProcessHelperTest extends TestCase
{
@@ -85,8 +84,8 @@ public function provideCommandsAndOutput()
EOT;
$errorMessage = 'An error occurred';
$args = new ProcessBuilder(array('php', '-r', 'echo 42;'));
$args = $args->getProcess()->getCommandLine();
$args = new Process(array('php', '-r', 'echo 42;'));
$args = $args->getCommandLine();
$successOutputProcessDebug = str_replace("'php' '-r' 'echo 42;'", $args, $successOutputProcessDebug);
return array(
@@ -26,7 +26,7 @@
"symfony/event-dispatcher": "~2.8|~3.0|~4.0",
"symfony/dependency-injection": "~3.3|~4.0",
"symfony/filesystem": "~2.8|~3.0|~4.0",
"symfony/process": "~2.8|~3.0|~4.0",
"symfony/process": "~3.3|~4.0",
"psr/log": "~1.0"
},
"suggest": {
@@ -36,7 +36,8 @@
"psr/log": "For using the console logger"
},
"conflict": {
"symfony/dependency-injection": "<3.3"
"symfony/dependency-injection": "<3.3",
"symfony/process": "<3.3"
},
"autoload": {
"psr-4": { "Symfony\\Component\\Console\\": "" },
@@ -1,6 +1,11 @@
CHANGELOG
=========
3.4.0
-----
* deprecated the ProcessBuilder class
3.3.0
-----
@@ -11,13 +11,17 @@
namespace Symfony\Component\Process;
@trigger_error(sprintf('The %s class is deprecated since version 3.4 and will be removed in 4.0. Use the Process class instead.', ProcessBuilder::class), E_USER_DEPRECATED);
use Symfony\Component\Process\Exception\InvalidArgumentException;
use Symfony\Component\Process\Exception\LogicException;
/**
* Process builder.
*
* @author Kris Wallsmith <kris@symfony.com>
*
* @deprecated since version 3.4, to be removed in 4.0. Use the Process class instead.
*/
class ProcessBuilder
{
@@ -120,13 +124,9 @@ public function setWorkingDirectory($cwd)
* @param bool $inheritEnv
*
* @return $this
*
* @deprecated since version 3.3, to be removed in 4.0.
*/
public function inheritEnvironmentVariables($inheritEnv = true)
{
@trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED);
$this->inheritEnv = $inheritEnv;
return $this;
@@ -221,13 +221,9 @@ public function setTimeout($timeout)
* @param string $value The option value
*
* @return $this
*
* @deprecated since version 3.3, to be removed in 4.0.
*/
public function setOption($name, $value)
{
@trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED);
$this->options[$name] = $value;
return $this;
@@ -14,11 +14,11 @@
use PHPUnit\Framework\TestCase;
use Symfony\Component\Process\ProcessBuilder;
/**
* @group legacy
*/
class ProcessBuilderTest extends TestCase
{
/**
* @group legacy
*/
public function testInheritEnvironmentVars()
{
$proc = ProcessBuilder::create()

0 comments on commit 1195c7d

Please sign in to comment.