Skip to content

Commit 531bfdb

Browse files
Switch to phpdotenv v5 (#33139)
1 parent e245cd7 commit 531bfdb

File tree

4 files changed

+10
-15
lines changed

4 files changed

+10
-15
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"symfony/routing": "^5.1",
4242
"symfony/var-dumper": "^5.1",
4343
"tijsverkoyen/css-to-inline-styles": "^2.2.2",
44-
"vlucas/phpdotenv": "^4.0",
44+
"vlucas/phpdotenv": "^5.0",
4545
"voku/portable-ascii": "^1.4.8"
4646
},
4747
"replace": {

src/Illuminate/Support/Env.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
namespace Illuminate\Support;
44

5-
use Dotenv\Repository\Adapter\EnvConstAdapter;
65
use Dotenv\Repository\Adapter\PutenvAdapter;
7-
use Dotenv\Repository\Adapter\ServerConstAdapter;
86
use Dotenv\Repository\RepositoryBuilder;
97
use PhpOption\Option;
108

@@ -54,16 +52,13 @@ public static function disablePutenv()
5452
public static function getRepository()
5553
{
5654
if (static::$repository === null) {
57-
$adapters = array_merge(
58-
[new EnvConstAdapter, new ServerConstAdapter],
59-
static::$putenv ? [new PutenvAdapter] : []
60-
);
55+
$builder = RepositoryBuilder::createWithDefaultAdapters();
6156

62-
static::$repository = RepositoryBuilder::create()
63-
->withReaders($adapters)
64-
->withWriters($adapters)
65-
->immutable()
66-
->make();
57+
if (static::$putenv) {
58+
$builder = $builder->addAdapter(PutenvAdapter::class);
59+
}
60+
61+
static::$repository = $builder->immutable()->make();
6762
}
6863

6964
return static::$repository;

src/Illuminate/Support/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"ramsey/uuid": "Required to use Str::uuid() (^4.0).",
4646
"symfony/process": "Required to use the composer class (^5.1).",
4747
"symfony/var-dumper": "Required to use the dd function (^5.1).",
48-
"vlucas/phpdotenv": "Required to use the Env class and env helper (^4.0)."
48+
"vlucas/phpdotenv": "Required to use the Env class and env helper (^5.0)."
4949
},
5050
"config": {
5151
"sort-packages": true

tests/Support/SupportHelpersTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,11 +637,11 @@ public function testEnvEscapedString()
637637
$this->assertSame('x"null"x', env('foo'));
638638
}
639639

640-
public function testGetFromENVFirst()
640+
public function testGetFromSERVERFirst()
641641
{
642642
$_ENV['foo'] = 'From $_ENV';
643643
$_SERVER['foo'] = 'From $_SERVER';
644-
$this->assertSame('From $_ENV', env('foo'));
644+
$this->assertSame('From $_SERVER', env('foo'));
645645
}
646646

647647
public function providesPregReplaceArrayData()

0 commit comments

Comments
 (0)