From 891312a0565c445767ed54bf1ad1158591717776 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Tue, 17 Oct 2023 15:54:46 +0800 Subject: [PATCH] eee --- src/Handler.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Handler.php b/src/Handler.php index d1227be..1630dac 100644 --- a/src/Handler.php +++ b/src/Handler.php @@ -8,6 +8,7 @@ use Kiri\Router\Format\ArrayFormat; use Kiri\Router\Format\IFormat; use Kiri\Router\Format\MixedFormat; use Kiri\Router\Format\OtherFormat; +use Kiri\Router\Format\ResponseFormat; use Kiri\Router\Format\VoidFormat; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; @@ -48,7 +49,14 @@ class Handler implements RequestHandlerInterface */ public function __construct(public array|Closure $handler, public array $parameter, public ReflectionNamedType $reflectionType) { - $this->format = di($this->types[$this->reflectionType->getName()]); + $type = match ($this->reflectionType->getName()) { + 'array' => ArrayFormat::class, + 'mixed', 'object' => MixedFormat::class, + 'int', 'string', 'bool' => OtherFormat::class, + 'void' => VoidFormat::class, + default => ResponseFormat::class + }; + $this->format = di($type); }