Skip to content

Commit

Permalink
Fix Process::inheritEnvironmentVariables() deprecation error (#1112)
Browse files Browse the repository at this point in the history
We're running into the following error when using `env()`:

> ERROR: The "Symfony\Component\Process\Process::inheritEnvironmentVariables()" method is deprecated since Symfony 4.4, env variables are always inherited.

The method call can be safely removed as the current required version of `symfony/process` is "^4.4.9 || ^5 || ^6".
  • Loading branch information
JanJakes authored Apr 21, 2022
1 parent 9d2af53 commit ccf8096
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 12 deletions.
5 changes: 0 additions & 5 deletions src/Common/ExecTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,6 @@ protected function execute($process, $output_callback = null)
}

if (isset($this->env)) {
// Symfony 4 will inherit environment variables by default, but until
// then, manually ensure they are inherited.
if (method_exists($this->process, 'inheritEnvironmentVariables')) {
$this->process->inheritEnvironmentVariables();
}
$this->process->setEnv($this->env);
}

Expand Down
7 changes: 0 additions & 7 deletions tests/integration/ExecTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,6 @@ public function testMultipleEnvVars()

public function testInheritEnv()
{
// Symfony < 3.2.1 does not inherit environment variables, so there's
// nothing to test if the function doesn't exist.
if (!method_exists('Symfony\Component\Process\Process', 'inheritEnvironmentVariables')) {
$this->markTestSkipped(
'Inheriting of environment variables is not supported.'
);
}
// With no environment variables set, count how many environment
// variables are present.
$task = $this->taskExec('env | wc -l')->interactive(false);
Expand Down

0 comments on commit ccf8096

Please sign in to comment.