Repository: Codeception/Codeception (php)

Issue:
ENV values in files overrides system values
#### What are you trying to achieve?

I have application built as docker image and run inside some orchestrator. This orchestrator passes env variables with database connection params to app.

Due to modern principles of running apps this application does not contain any concrete configuration inside image, only some defaults, even for dev and test stages. It even has no pre-configured stages inside, just long list of env vars.

So this app need to use env variables from system, and for those which not set it may use some defaults in .env files. 

In codeception v.5 this behavior was broken.

In `\Codeception\Lib\ParamsLoader::loadDotEnvFile` variables from file populated with override flag:
```
        if (class_exists(SymfonyDotenv::class)) {
            $symfonyDotEnv = new SymfonyDotenv();
            $values = $symfonyDotEnv->parse(self::getFileContents($file), $file);
            $symfonyDotEnv->populate($values, true);
            return $values;
        }
```

This is wrong behavior, because system env is more priore than values commited in file. System envs must be used to override defaults in file.

If some legacy application (not in docker) stores it's real database connection params in this files, behavior with more proir system envs does not broke it, but gives ability to override this values by setting them in `.bashrc`.

I can't change this behavior by setting `env` param in `codeception.yml` like this:

```yml
params:
    - .env
    - .env.test
    - env
```

or this

```yml
params:
    - env
    - .env
    - .env.test
```

This `env` parameter injected by function `\Codeception\Lib\ParamsLoader::loadEnvironmentVars`

```
    private static function loadEnvironmentVars(): array
    {
        return $_SERVER;
    }
```

If it stands first in list, it fill be overriden by dotenv files. if it stands last, it used already overriden `$_SERVER`.

My proposal is not to override existing env vars by files:
```
$symfonyDotEnv->populate($values, false);
```

In this case i may get any behavior by changing positions of params files.


#### What do you get instead?

Can not have behavior where system environment is prior to values in .env files

### Details

* Codeception version: 5.0.0-RC3
* PHP Version: 8.1.1
* Operating System: Linux
* Installation type: Composer
* Suite configuration:

```yml
params:
    - .env
    - .env.test
    - env
```


Pull request description:
Loading .env file must not override existing environment variables
Fixes #6473 

Patch:
diff --git a/src/Codeception/Lib/ParamsLoader.php b/src/Codeception/Lib/ParamsLoader.php
index 262866c68..b417787e3 100644
--- a/src/Codeception/Lib/ParamsLoader.php
+++ b/src/Codeception/Lib/ParamsLoader.php
@@ -164,7 +164,7 @@ class_exists(PhpDotenv::class)
         if (class_exists(SymfonyDotenv::class)) {
             $symfonyDotEnv = new SymfonyDotenv();
             $values = $symfonyDotEnv->parse(self::getFileContents($file), $file);
-            $symfonyDotEnv->populate($values, true);
+            $symfonyDotEnv->populate($values);
             return $values;
         }
 


Test patch:
diff --git a/tests/cli/ConfigParamsCest.php b/tests/cli/ConfigParamsCest.php
index 02df0acbd..e431145ae 100644
--- a/tests/cli/ConfigParamsCest.php
+++ b/tests/cli/ConfigParamsCest.php
@@ -2,54 +2,69 @@
 
 declare(strict_types=1);
 
+use Codeception\Attribute\Before;
+
 final class ConfigParamsCest
 {
-    public function checkYamlParamsPassed(CliGuy $I)
+    private function moveToTestDir(CliGuy $I): void
     {
+        static $prepared = false;
+
         $I->amInPath('tests/data/params');
+
+        if ($prepared) {
+            return;
+        }
+        $I->executeCommand('build');
+        $prepared = true;
+    }
+
+    #[Before('moveToTestDir')]
+    public function checkYamlParamsPassed(CliGuy $I)
+    {
         $I->executeCommand('run -c codeception_yaml.yml dummy');
         $I->seeInShellOutput('OK (1 test');
     }
 
+    #[Before('moveToTestDir')]
     public function checkDotEnvParamsPassed(CliGuy $I)
     {
-        $I->amInPath('tests/data/params');
         $I->executeCommand('run -c codeception_dotenv.yml dummy');
         $I->seeInShellOutput('OK (1 test');
     }
 
+    #[Before('moveToTestDir')]
     public function checkComplexDotEnvParamsPassed(CliGuy $I)
     {
-        $I->amInPath('tests/data/params');
         $I->executeCommand('run -c codeception_dotenv2.yml dummy');
         $I->seeInShellOutput('OK (1 test');
     }
 
+    #[Before('moveToTestDir')]
     public function checkEnvParamsPassed(CliGuy $I)
     {
-        $I->amInPath('tests/data/params');
         $I->executeCommand('run --no-exit dummy');
         $I->seeInShellOutput('FAILURES');
         $I->seeInShellOutput("Failed asserting that an array contains 'val1'");
     }
 
+    #[Before('moveToTestDir')]
     public function checkParamsPassedInSelf(CliGuy $I)
     {
-        $I->amInPath('tests/data/params');
         $I->executeCommand('run -c codeception_self.yml dummy');
         $I->seeInShellOutput('OK (1 test');
     }
 
+    #[Before('moveToTestDir')]
     public function checkXmlParamsPassed(CliGuy $I)
     {
-        $I->amInPath('tests/data/params');
         $I->executeCommand('run -c codeception_xml.yml dummy');
         $I->seeInShellOutput('OK (1 test');
     }
 
+    #[Before('moveToTestDir')]
     public function checkNonStringParamsAreEncodedProperly(CliGuy $I)
     {
-        $I->amInPath('tests/data/params');
         $I->executeCommand('run -c codeception_yaml.yml complex');
         $I->seeInShellOutput('OK (1 test');
     }