Skip to content

Commit 34145cb

Browse files
committed
Do not mix $_ENV with $_SERVER, except for ENVIRONMENT
1 parent f1d3b7f commit 34145cb

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

boot/helpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,5 +330,5 @@ function model(string $class) : Model
330330
*/
331331
function env(string $key, mixed $default = null) : mixed
332332
{
333-
return $_ENV[$key] ?? $_SERVER[$key] ?? $default;
333+
return $_ENV[$key] ?? $default;
334334
}

boot/init.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
*/
88
if (is_file(__DIR__ . '/../.env.php')) {
99
require __DIR__ . '/../.env.php';
10-
foreach ($_ENV as $key => $value) {
11-
$_SERVER[$key] = $value;
10+
if (isset($_ENV['ENVIRONMENT'])) {
11+
$_SERVER['ENVIRONMENT'] = $_ENV['ENVIRONMENT'];
1212
}
1313
}
1414

tests/boot/HelpersTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ public function testEnv() : void
264264
$_SERVER['foo'] = 'bar';
265265
$_SERVER['bar'] = 'baz';
266266
self::assertSame('foo', env('foo'));
267-
self::assertSame('baz', env('bar'));
267+
self::assertNull(env('bar'));
268268
self::assertNull(env('unknown'));
269269
}
270270
}

0 commit comments

Comments
 (0)