Skip to content

Commit 3bbd14d

Browse files
Improved tests
1 parent 322fdff commit 3bbd14d

File tree

6 files changed

+365
-229
lines changed

6 files changed

+365
-229
lines changed

src/DotEnvAdapters/DotEnvAdapterPicker.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public static function pickAdapter(array $order = ['vlucas', 'symfony']): DotEnv
5151
}
5252

5353
/**
54-
* Detect the version of vlucas/phpdotenv installed.
54+
* Detect the version of vlucas/phpdotenv installed and return the appropriate adapter.
5555
*
5656
* @return DotEnvAdapterInterface|null
5757
*/
@@ -72,7 +72,7 @@ public static function detectVLucasPhpDotEnv()
7272
}
7373

7474
/**
75-
* Detect the version of symfony/dotenv installed.
75+
* Detect the version of symfony/dotenv installed and return the appropriate adapter.
7676
*
7777
* @return DotEnvAdapterInterface|null
7878
*/

src/DotEnvAdapters/DotEnvAdapterTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ trait DotEnvAdapterTrait
1515
* @param string $path The path to the .env file.
1616
* @return string
1717
*/
18-
protected function getDir(string $path): string
18+
private function getDir(string $path): string
1919
{
2020
$temp = explode('/', $path);
2121
array_pop($temp); // remove the filename
@@ -28,7 +28,7 @@ protected function getDir(string $path): string
2828
* @param string $path The path to the .env file.
2929
* @return string
3030
*/
31-
protected function getFilename(string $path): string
31+
private function getFilename(string $path): string
3232
{
3333
$temp = explode('/', $path);
3434
return array_pop($temp);

src/DotEnvAdapters/VLucas/VLucasAdapterV1.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ protected function importWillUpdateGetenvValues(): bool
6565
{
6666
// custom class VLucasV1Dotenv overrides Dotenv's setEnvironmentVariable() method
6767
// to remove the putenv() and $_ENV lines. HOWEVER:
68-
// version <= 1.0.6 don't have the setEnvironmentVariable() method
69-
// version <= 1.0.9 some issues in overriding setEnvironmentVariable()
70-
// version ^1.1.0 is required in composer.json to avoid problems with these old versions
68+
// - version <= 1.0.6 doesn't use the setEnvironmentVariable() method in the first place
69+
// - version <= 1.0.9 has some issues in overriding setEnvironmentVariable()
70+
// - version ^1.1.0 is required in composer.json to avoid problems with these old versions
7171

7272
// otherwise…
7373
// not needed because vlucas/phpdotenv v1 is being used in a way where

src/Misc/GetenvSupport.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,11 @@ public static function getAllGetenvVariables(): array
2121
}
2222

2323
// getenv() requires a $key to be passed to it before PHP 7.1
24-
try {
25-
26-
return @(array) getenv();
27-
28-
} catch (Throwable $e) {
29-
30-
// if needed, get the getenv() values individually
31-
$values = [];
32-
foreach (array_keys($_ENV) as $key) {
33-
$values[$key] = getenv($key);
34-
}
35-
return $values;
24+
if (version_compare(PHP_VERSION, '7.1.0', '<')) {
25+
return self::getParticularGetenvVariables(array_keys($_ENV));
3626
}
27+
28+
return @(array) getenv();
3729
}
3830

3931
/**

0 commit comments

Comments
 (0)