Skip to content

Commit afe721e

Browse files
committed
Read environment variable from superglobals
The Dotenv component has recently been switched to using superglobals instead of putenv(). Let us support both and give priority to superglobals. Closes #31857
1 parent e8975e2 commit afe721e

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,32 @@ public function shutdown()
210210
});
211211
}
212212

213+
/**
214+
* @return mixed string|false
215+
*/
216+
private function getModeFromEnvironment()
217+
{
218+
if (false !== $this->mode) {
219+
return $this->mode;
220+
}
221+
222+
if (isset($_SERVER['SYMFONY_DEPRECATIONS_HELPER'])) {
223+
return $this->mode = $_SERVER['SYMFONY_DEPRECATIONS_HELPER'];
224+
}
225+
226+
if (isset($_ENV['SYMFONY_DEPRECATIONS_HELPER'])) {
227+
return $this->mode = $_ENV['SYMFONY_DEPRECATIONS_HELPER'];
228+
}
229+
230+
return $this->mode = getenv('SYMFONY_DEPRECATIONS_HELPER');
231+
}
232+
213233
private function getConfiguration()
214234
{
215235
if (null !== $this->configuration) {
216236
return $this->configuration;
217237
}
218-
if (false === $mode = $this->mode) {
219-
$mode = getenv('SYMFONY_DEPRECATIONS_HELPER');
220-
}
238+
$mode = $this->getModeFromEnvironment();
221239
if ('strict' === $mode) {
222240
return $this->configuration = Configuration::inStrictMode();
223241
}

0 commit comments

Comments
 (0)