Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: implicit null warnings for test #161

Merged
merged 1 commit into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Http/Adapter/FPM/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Adapter/Swoole/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Adapter/Swoole/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -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, [
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Adapter/SwooleCoroutine/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -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, [
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Files.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion tests/HttpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading