From df66421b89527f751a0500aaf1e6bd644421bf9d Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Sat, 28 Mar 2026 20:43:57 +0530 Subject: [PATCH] Fix getEnv nullable default deprecation --- composer.json | 6 +++--- composer.lock | 2 +- src/Platform/Platform.php | 2 +- tests/unit/GetEnvTest.php | 7 +++++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 49cf9fc..e72004c 100644 --- a/composer.json +++ b/composer.json @@ -18,10 +18,10 @@ "php": ">=8.1", "ext-json": "*", "ext-redis": "*", - "utopia-php/servers": "0.3.*", - "utopia-php/http": "0.34.*", "utopia-php/cli": "0.23.*", - "utopia-php/queue": "0.17.*" + "utopia-php/http": "0.34.*", + "utopia-php/queue": "0.17.*", + "utopia-php/servers": "0.3.*" }, "require-dev": { "phpunit/phpunit": "^9.3", diff --git a/composer.lock b/composer.lock index 764c985..b9069e2 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "6a7730696e8af5a67acd42e3aaf20350", + "content-hash": "63db09ede46a61cf474e59a26ff3044e", "packages": [ { "name": "brick/math", diff --git a/src/Platform/Platform.php b/src/Platform/Platform.php index eb2b3a6..31d41d9 100644 --- a/src/Platform/Platform.php +++ b/src/Platform/Platform.php @@ -354,7 +354,7 @@ public function setWorker(Server $worker): self * @param string|null $default * @return mixed */ - public function getEnv(string $key, string $default = null): mixed + public function getEnv(string $key, ?string $default = null): mixed { return $_SERVER[$key] ?? $default; } diff --git a/tests/unit/GetEnvTest.php b/tests/unit/GetEnvTest.php index 0eb6059..73b9c34 100644 --- a/tests/unit/GetEnvTest.php +++ b/tests/unit/GetEnvTest.php @@ -6,9 +6,12 @@ class GetEnvTest extends TestCase { - public function testGetEnv() + public function testGetEnv(): void { $platform = new Mock(); - $this->assertEquals(3, $platform->getEnv('argc')); + + $this->assertSame($_SERVER['argc'] ?? null, $platform->getEnv('argc')); + $this->assertSame('fallback', $platform->getEnv('UTOPIA_PLATFORM_MISSING_ENV', 'fallback')); + $this->assertNull($platform->getEnv('UTOPIA_PLATFORM_MISSING_ENV')); } }