Skip to content

Commit fec65a9

Browse files
Bump symfony/dotenv to v5.4 minimum
1 parent 9df660e commit fec65a9

File tree

2 files changed

+5
-25
lines changed

2 files changed

+5
-25
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"symfony/process": "^6.4|^7.4|^8.0"
2323
},
2424
"conflict": {
25-
"composer/semver": "<1.7.2"
25+
"composer/semver": "<1.7.2",
26+
"symfony/dotenv": "<5.4"
2627
},
2728
"autoload": {
2829
"psr-4": {

src/Command/DumpEnvCommand.php

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,7 @@ private function loadEnv(string $path, ?string $env, array $runtime): array
101101
putenv('SYMFONY_DOTENV_VARS='.$_SERVER['SYMFONY_DOTENV_VARS']);
102102

103103
try {
104-
if (method_exists(Dotenv::class, 'usePutenv')) {
105-
$dotenv = new Dotenv();
106-
} else {
107-
$dotenv = new Dotenv(false);
108-
}
104+
$dotenv = new Dotenv();
109105

110106
if (!$env && file_exists($p = "$path.local")) {
111107
$env = $_ENV[$envKey] = $dotenv->parse(file_get_contents($p), $p)[$envKey] ?? null;
@@ -117,29 +113,12 @@ private function loadEnv(string $path, ?string $env, array $runtime): array
117113

118114
$testEnvs = $runtime['test_envs'] ?? ['test'];
119115

120-
if (method_exists($dotenv, 'loadEnv')) {
121-
$dotenv->loadEnv($path, $envKey, 'dev', $testEnvs);
122-
} else {
123-
// fallback code in case your Dotenv component is not 4.2 or higher (when loadEnv() was added)
124-
$dotenv->load(file_exists($path) || !file_exists($p = "$path.dist") ? $path : $p);
125-
126-
if (!\in_array($env, $testEnvs, true) && file_exists($p = "$path.local")) {
127-
$dotenv->load($p);
128-
}
129-
130-
if (file_exists($p = "$path.$env")) {
131-
$dotenv->load($p);
132-
}
133-
134-
if (file_exists($p = "$path.$env.local")) {
135-
$dotenv->load($p);
136-
}
137-
}
116+
$dotenv->loadEnv($path, $envKey, 'dev', $testEnvs);
138117

139118
unset($_ENV['SYMFONY_DOTENV_VARS'], $_ENV['SYMFONY_DOTENV_PATH']);
140119
$env = $_ENV;
141120
} finally {
142-
list($_SERVER, $_ENV) = $globalsBackup;
121+
[$_SERVER, $_ENV] = $globalsBackup;
143122
}
144123

145124
return $env;

0 commit comments

Comments
 (0)