From 032a8630fe9bad3e46c4676ee039c11f14c1baf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Sun, 16 Apr 2023 19:36:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Constrict/Message.php | 4 +++- src/Response.php | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Constrict/Message.php b/src/Constrict/Message.php index c05d2f7..9d9cfd3 100644 --- a/src/Constrict/Message.php +++ b/src/Constrict/Message.php @@ -37,9 +37,11 @@ class Message extends Component implements MessageInterface /** * */ - public function init(): void + public function __construct() { $this->stream = new Stream(); + + parent::__construct(); } diff --git a/src/Response.php b/src/Response.php index d452652..f1b4d36 100644 --- a/src/Response.php +++ b/src/Response.php @@ -5,6 +5,7 @@ namespace Kiri\Router; use InvalidArgumentException; use Kiri\Di\Context; +use Kiri\Router\Constrict\ConstrictResponse; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\StreamInterface; @@ -78,7 +79,7 @@ class Response implements ResponseInterface * @param ContentType $type * @return Response */ - public function write(mixed $data, int $statusCode = 200, ContentType $type = ContentType::HTML): static + public function write(mixed $data, int $statusCode = 200, ContentType $type = ContentType::HTML): ResponseInterface { return $this->__call__(__FUNCTION__, $data, $statusCode, $type); } @@ -92,7 +93,7 @@ class Response implements ResponseInterface private function __call__(string $method, ...$params): mixed { if (!Context::exists(ResponseInterface::class)) { - $response = Context::set(ResponseInterface::class, new static()); + $response = Context::set(ResponseInterface::class, new ConstrictResponse()); } else { $response = Context::get(ResponseInterface::class); }