diff --git a/composer.json b/composer.json index 8fdc1b5c..2380321a 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,8 @@ "symfony/process": "^6.4|^7.4|^8.0" }, "conflict": { - "composer/semver": "<1.7.2" + "composer/semver": "<1.7.2", + "symfony/dotenv": "<5.4" }, "autoload": { "psr-4": { diff --git a/src/Command/DumpEnvCommand.php b/src/Command/DumpEnvCommand.php index 7b109dcf..e5a32bcd 100644 --- a/src/Command/DumpEnvCommand.php +++ b/src/Command/DumpEnvCommand.php @@ -101,11 +101,7 @@ private function loadEnv(string $path, ?string $env, array $runtime): array putenv('SYMFONY_DOTENV_VARS='.$_SERVER['SYMFONY_DOTENV_VARS']); try { - if (method_exists(Dotenv::class, 'usePutenv')) { - $dotenv = new Dotenv(); - } else { - $dotenv = new Dotenv(false); - } + $dotenv = new Dotenv(); if (!$env && file_exists($p = "$path.local")) { $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 $testEnvs = $runtime['test_envs'] ?? ['test']; - if (method_exists($dotenv, 'loadEnv')) { - $dotenv->loadEnv($path, $envKey, 'dev', $testEnvs); - } else { - // fallback code in case your Dotenv component is not 4.2 or higher (when loadEnv() was added) - $dotenv->load(file_exists($path) || !file_exists($p = "$path.dist") ? $path : $p); - - if (!\in_array($env, $testEnvs, true) && file_exists($p = "$path.local")) { - $dotenv->load($p); - } - - if (file_exists($p = "$path.$env")) { - $dotenv->load($p); - } - - if (file_exists($p = "$path.$env.local")) { - $dotenv->load($p); - } - } + $dotenv->loadEnv($path, $envKey, 'dev', $testEnvs); unset($_ENV['SYMFONY_DOTENV_VARS'], $_ENV['SYMFONY_DOTENV_PATH']); $env = $_ENV; } finally { - list($_SERVER, $_ENV) = $globalsBackup; + [$_SERVER, $_ENV] = $globalsBackup; } return $env;