From f982871f3447fc3e147c26e67e02f56f593f3b6b Mon Sep 17 00:00:00 2001 From: ChiragAgg5k Date: Fri, 3 Jan 2025 12:02:28 +0530 Subject: [PATCH] fix: implicit null warnings for test --- src/Http/Adapter/FPM/Request.php | 2 +- src/Http/Adapter/Swoole/Request.php | 2 +- src/Http/Adapter/Swoole/Server.php | 2 +- src/Http/Adapter/SwooleCoroutine/Server.php | 2 +- src/Http/Files.php | 2 +- src/Http/Http.php | 2 +- src/Http/Request.php | 2 +- src/Http/Response.php | 4 ++-- tests/HttpTest.php | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Http/Adapter/FPM/Request.php b/src/Http/Adapter/FPM/Request.php index bdc8ebf5..ca5db43e 100644 --- a/src/Http/Adapter/FPM/Request.php +++ b/src/Http/Adapter/FPM/Request.php @@ -36,7 +36,7 @@ public function getRawPayload(): string * @param string|null $default * @return string|null */ - public function getServer(string $key, string $default = null): ?string + public function getServer(string $key, ?string $default = null): ?string { return $_SERVER[$key] ?? $default; } diff --git a/src/Http/Adapter/Swoole/Request.php b/src/Http/Adapter/Swoole/Request.php index d93310d2..e2600648 100644 --- a/src/Http/Adapter/Swoole/Request.php +++ b/src/Http/Adapter/Swoole/Request.php @@ -43,7 +43,7 @@ public function getRawPayload(): string * @param string|null $default * @return string|null */ - public function getServer(string $key, string $default = null): ?string + public function getServer(string $key, ?string $default = null): ?string { return $this->swoole->server[$key] ?? $default; } diff --git a/src/Http/Adapter/Swoole/Server.php b/src/Http/Adapter/Swoole/Server.php index 0fc63b47..7073520d 100755 --- a/src/Http/Adapter/Swoole/Server.php +++ b/src/Http/Adapter/Swoole/Server.php @@ -10,7 +10,7 @@ class Server extends Adapter { protected SwooleServer $server; - public function __construct(string $host, string $port = null, array $settings = []) + public function __construct(string $host, ?string $port = null, array $settings = []) { $this->server = new SwooleServer($host, $port); $this->server->set(\array_merge($settings, [ diff --git a/src/Http/Adapter/SwooleCoroutine/Server.php b/src/Http/Adapter/SwooleCoroutine/Server.php index c3a8f545..7fe6b9f8 100644 --- a/src/Http/Adapter/SwooleCoroutine/Server.php +++ b/src/Http/Adapter/SwooleCoroutine/Server.php @@ -9,7 +9,7 @@ class Server extends Adapter { protected SwooleServer $server; - public function __construct(string $host, string $port = null, array $settings = []) + public function __construct(string $host, ?string $port = null, array $settings = []) { $this->server = new SwooleServer($host, $port, false, true); $this->server->set(\array_merge($settings, [ diff --git a/src/Http/Files.php b/src/Http/Files.php index 5ecd353f..b5fc5199 100644 --- a/src/Http/Files.php +++ b/src/Http/Files.php @@ -83,7 +83,7 @@ public function getCount(): int * * @throws \Exception */ - public function load(string $directory, string $root = null): void + public function load(string $directory, ?string $root = null): void { if (!is_readable($directory)) { throw new Exception("Failed to load directory: {$directory}"); diff --git a/src/Http/Http.php b/src/Http/Http.php index 3a091c6a..d9fb7a3f 100755 --- a/src/Http/Http.php +++ b/src/Http/Http.php @@ -264,7 +264,7 @@ public static function addRoute(string $method, string $url): Route * * @throws \Exception */ - public function loadFiles(string $directory, string $root = null): void + public function loadFiles(string $directory, ?string $root = null): void { $this->files->load($directory, $root); } diff --git a/src/Http/Request.php b/src/Http/Request.php index e8894e04..38151339 100755 --- a/src/Http/Request.php +++ b/src/Http/Request.php @@ -137,7 +137,7 @@ abstract public function getRawPayload(): string; * @param string|null $default * @return string|null */ - abstract public function getServer(string $key, string $default = null): ?string; + abstract public function getServer(string $key, ?string $default = null): ?string; /** * Set server diff --git a/src/Http/Response.php b/src/Http/Response.php index 66a0eeaa..cc156457 100755 --- a/src/Http/Response.php +++ b/src/Http/Response.php @@ -364,7 +364,7 @@ public function enablePayload(): static * @param string $key * @param string $value */ - public function addHeader(string $key, string $value): static + public function addHeader(string $key, ?string $value): static { $this->headers[$key] = $value; @@ -413,7 +413,7 @@ public function getHeaders(): array * @param bool $httponly * @param string $sameSite */ - public function addCookie(string $name, string $value = null, int $expire = null, string $path = null, string $domain = null, bool $secure = null, bool $httponly = null, string $sameSite = null): static + public function addCookie(string $name, ?string $value = null, ?int $expire = null, ?string $path = null, ?string $domain = null, ?bool $secure = null, ?bool $httponly = null, ?string $sameSite = null): static { $name = strtolower($name); diff --git a/tests/HttpTest.php b/tests/HttpTest.php index 70f41a27..3aac0bd5 100755 --- a/tests/HttpTest.php +++ b/tests/HttpTest.php @@ -578,7 +578,7 @@ public function providerRouteMatching(): array /** * @dataProvider providerRouteMatching */ - public function testCanMatchRoute(string $method, string $path, string $url = null): void + public function testCanMatchRoute(string $method, string $path, ?string $url = null): void { $url ??= $path; $expected = null;