From 2254af839a1bd267c1edbf241faa062a7e7b9991 Mon Sep 17 00:00:00 2001 From: Cydrick Nonog Date: Tue, 17 May 2022 20:46:52 +0800 Subject: [PATCH 1/2] fix: add typehint in Request.php --- src/Swoole/Request.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Swoole/Request.php b/src/Swoole/Request.php index 2a8fd48..53b5bfd 100644 --- a/src/Swoole/Request.php +++ b/src/Swoole/Request.php @@ -31,7 +31,7 @@ public function __construct(SwooleRequest $request) * @param mixed $default * @return mixed */ - public function getParam(string $key, $default = null): mixed + public function getParam(string $key, mixed $default = null): mixed { switch($this->getMethod()) { case self::METHOD_GET: @@ -70,8 +70,6 @@ public function getParams(): array default: return (!empty($this->swoole->get)) ? $this->swoole->get : []; } - - return []; } /** @@ -83,7 +81,7 @@ public function getParams(): array * @param mixed $default * @return mixed */ - public function getQuery(string $key, $default = null): mixed + public function getQuery(string $key, mixed $default = null): mixed { return (isset($this->swoole->get[$key])) ? $this->swoole->get[$key] : $default; } @@ -97,7 +95,7 @@ public function getQuery(string $key, $default = null): mixed * @param mixed $default * @return mixed */ - public function getPayload(string $key, $default = null): mixed + public function getPayload(string $key, mixed $default = null): mixed { $payload = $this->generateInput(); @@ -113,7 +111,7 @@ public function getPayload(string $key, $default = null): mixed * @param mixed $default * @return mixed */ - public function getServer(string $key, $default = null): mixed + public function getServer(string $key, mixed $default = null): mixed { return (isset($this->swoole->server) && isset($this->swoole->server[$key])) ? $this->swoole->server[$key] : $default; } @@ -207,6 +205,7 @@ public function getURI(): string * * Return HTTP referer header * + * @param string $default * @return string */ public function getReferer(string $default = ''): string @@ -219,6 +218,7 @@ public function getReferer(string $default = ''): string * * Return HTTP origin header * + * @param string $default * @return string */ public function getOrigin(string $default = ''): string @@ -231,6 +231,7 @@ public function getOrigin(string $default = ''): string * * Return HTTP user agent header * + * @param string $default * @return string */ public function getUserAgent(string $default = ''): string @@ -243,6 +244,7 @@ public function getUserAgent(string $default = ''): string * * Return HTTP accept header * + * @param string $default * @return string */ public function getAccept(string $default = ''): string @@ -258,7 +260,7 @@ public function getAccept(string $default = ''): string * @param string $key * @return array */ - public function getFiles($key): array + public function getFiles(string $key): array { $key = strtolower($key); return (isset($this->swoole->files[$key])) ? $this->swoole->files[$key] : []; From 1d667041ed5f51effbd1891d1e01d48f33cd1763 Mon Sep 17 00:00:00 2001 From: Cydrick Nonog Date: Tue, 17 May 2022 21:03:48 +0800 Subject: [PATCH 2/2] doc: update readme.md to use php 8.0 or later --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 479a3cb..95f6c0b 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ $http->start(); ## System Requirements -Utopia Framework requires PHP 7.4 or later. We recommend using the latest PHP version whenever possible. +Utopia Framework requires PHP 8.0 or later. We recommend using the latest PHP version whenever possible. ## Authors