From ccf80963abf11bdb8e90659aa99a7449b21e9452 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Jake=C5=A1?= Date: Thu, 21 Apr 2022 11:29:58 +0200 Subject: [PATCH] Fix `Process::inheritEnvironmentVariables()` deprecation error (#1112) 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". --- src/Common/ExecTrait.php | 5 ----- tests/integration/ExecTest.php | 7 ------- 2 files changed, 12 deletions(-) diff --git a/src/Common/ExecTrait.php b/src/Common/ExecTrait.php index 6b380361a..9959d3042 100644 --- a/src/Common/ExecTrait.php +++ b/src/Common/ExecTrait.php @@ -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); } diff --git a/tests/integration/ExecTest.php b/tests/integration/ExecTest.php index ab2791a63..64c616c4c 100644 --- a/tests/integration/ExecTest.php +++ b/tests/integration/ExecTest.php @@ -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);