From b149e6147a9a3dfdf3e3543eead932877d251f6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Tue, 7 Sep 2021 14:00:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- http-server/Message/Message.php | 36 ++++++++++++++++----------------- http-server/Server.php | 2 +- http-server/ServerManager.php | 5 ++--- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/http-server/Message/Message.php b/http-server/Message/Message.php index c217b963..9956ec23 100644 --- a/http-server/Message/Message.php +++ b/http-server/Message/Message.php @@ -60,7 +60,7 @@ trait Message */ public function withCookie($name, $value = null, $expires = null, $path = null, $domain = null, $secure = null, $httponly = null, $samesite = null, $priority = null): static { - $this->cookies[$name] = [$value, $expires, $path, $domain, $secure, $httponly, $samesite, $priority]; + $this->cookies[$name] = [$value, $expires, $path, $domain, $secure, $httponly, $samesite, $priority]; return $this; } @@ -74,27 +74,27 @@ trait Message } - /** - * @return string|null - */ + /** + * @return string|null + */ #[Pure] public function getAccessControlAllowOrigin(): ?string { return $this->getHeaderLine('Access-Control-Allow-Origin'); } - /** - * @return string|null - */ + /** + * @return string|null + */ #[Pure] public function getAccessControlAllowHeaders(): ?string { return $this->getHeaderLine('Access-Control-Allow-Headers'); } - /** - * @return string|null - */ + /** + * @return string|null + */ #[Pure] public function getAccessControlRequestMethod(): ?string { return $this->getHeaderLine('Access-Control-Request-Method'); @@ -107,7 +107,7 @@ trait Message */ public function withProtocolVersion($version): static { - $this->version = $version; + $this->version = $version; return $this; } @@ -201,7 +201,7 @@ trait Message if (!is_array($value)) { $value = [$value]; } - $this->headers[$name] = $value; + $this->headers[$name] = $value; return $this; } @@ -217,7 +217,7 @@ trait Message if (!array_key_exists($name, $this->headers)) { throw new \Exception('Headers `' . $name . '` not exists.'); } - $this->headers[$name][] = $value; + $this->headers[$name][] = $value; return $this; } @@ -248,7 +248,7 @@ trait Message */ public function withBody(StreamInterface $body): static { - $this->stream = $body; + $this->stream = $body; return $this; } @@ -281,10 +281,10 @@ trait Message } - /** - * @param $host - * @return \Server\Message\Request|\Server\Message\Response - */ + /** + * @param $host + * @return \Server\Message\Request|\Server\Message\Response + */ public function redirectTo($host) { return $this->withHeader('Location', $host) diff --git a/http-server/Server.php b/http-server/Server.php index 866f4416..b2bc4840 100644 --- a/http-server/Server.php +++ b/http-server/Server.php @@ -82,7 +82,7 @@ class Server extends HttpService foreach ($processes as $process) { $this->manager->addProcess($process); } - Runtime::enableCoroutine(true, SWOOLE_HOOK_ALL ^ SWOOLE_HOOK_BLOCKING_FUNCTION); +// Runtime::enableCoroutine(true, SWOOLE_HOOK_ALL ^ SWOOLE_HOOK_BLOCKING_FUNCTION); return $this->manager->getServer()->start(); } diff --git a/http-server/ServerManager.php b/http-server/ServerManager.php index dc6af1d6..06395c75 100644 --- a/http-server/ServerManager.php +++ b/http-server/ServerManager.php @@ -77,7 +77,6 @@ class ServerManager /** - * @throws NotFindClassException * @throws ReflectionException * @throws ConfigException */ @@ -202,8 +201,8 @@ class ServerManager /** - * @param $key - * @param $value + * @param string $key + * @param string|int $value */ public static function setEnv(string $key, string|int $value): void {