Skip to content

Commit 16d385e

Browse files
authored
Merge pull request #55 from utopia-php/codex/fix-getenv-nullable-deprecation
[codex] Fix getEnv nullable default deprecation
2 parents cfe3dc3 + df66421 commit 16d385e

4 files changed

Lines changed: 10 additions & 7 deletions

File tree

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
"php": ">=8.1",
1919
"ext-json": "*",
2020
"ext-redis": "*",
21-
"utopia-php/servers": "0.3.*",
22-
"utopia-php/http": "0.34.*",
2321
"utopia-php/cli": "0.23.*",
24-
"utopia-php/queue": "0.17.*"
22+
"utopia-php/http": "0.34.*",
23+
"utopia-php/queue": "0.17.*",
24+
"utopia-php/servers": "0.3.*"
2525
},
2626
"require-dev": {
2727
"phpunit/phpunit": "^9.3",

composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Platform/Platform.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ public function setWorker(Server $worker): self
354354
* @param string|null $default
355355
* @return mixed
356356
*/
357-
public function getEnv(string $key, string $default = null): mixed
357+
public function getEnv(string $key, ?string $default = null): mixed
358358
{
359359
return $_SERVER[$key] ?? $default;
360360
}

tests/unit/GetEnvTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66

77
class GetEnvTest extends TestCase
88
{
9-
public function testGetEnv()
9+
public function testGetEnv(): void
1010
{
1111
$platform = new Mock();
12-
$this->assertEquals(3, $platform->getEnv('argc'));
12+
13+
$this->assertSame($_SERVER['argc'] ?? null, $platform->getEnv('argc'));
14+
$this->assertSame('fallback', $platform->getEnv('UTOPIA_PLATFORM_MISSING_ENV', 'fallback'));
15+
$this->assertNull($platform->getEnv('UTOPIA_PLATFORM_MISSING_ENV'));
1316
}
1417
}

0 commit comments

Comments
 (0)