This commit is contained in:
2023-04-16 19:36:28 +08:00
parent 347f4fa0ae
commit 032a8630fe
2 changed files with 6 additions and 3 deletions
+3 -1
View File
@@ -37,9 +37,11 @@ class Message extends Component implements MessageInterface
/** /**
* *
*/ */
public function init(): void public function __construct()
{ {
$this->stream = new Stream(); $this->stream = new Stream();
parent::__construct();
} }
+3 -2
View File
@@ -5,6 +5,7 @@ namespace Kiri\Router;
use InvalidArgumentException; use InvalidArgumentException;
use Kiri\Di\Context; use Kiri\Di\Context;
use Kiri\Router\Constrict\ConstrictResponse;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface; use Psr\Http\Message\StreamInterface;
@@ -78,7 +79,7 @@ class Response implements ResponseInterface
* @param ContentType $type * @param ContentType $type
* @return Response * @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); return $this->__call__(__FUNCTION__, $data, $statusCode, $type);
} }
@@ -92,7 +93,7 @@ class Response implements ResponseInterface
private function __call__(string $method, ...$params): mixed private function __call__(string $method, ...$params): mixed
{ {
if (!Context::exists(ResponseInterface::class)) { if (!Context::exists(ResponseInterface::class)) {
$response = Context::set(ResponseInterface::class, new static()); $response = Context::set(ResponseInterface::class, new ConstrictResponse());
} else { } else {
$response = Context::get(ResponseInterface::class); $response = Context::get(ResponseInterface::class);
} }