eee
This commit is contained in:
+5
-27
@@ -42,40 +42,18 @@ class Handler implements RequestHandlerInterface
|
||||
protected ContainerInterface $container;
|
||||
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected array $parameters;
|
||||
|
||||
|
||||
/**
|
||||
* @param array|Closure $handler
|
||||
* @param ReflectionMethod|ReflectionFunction $parameter
|
||||
* @param array $parameters
|
||||
* @param string|null $parameter
|
||||
*/
|
||||
public function __construct(public array|Closure $handler, ReflectionMethod|ReflectionFunction $parameter)
|
||||
public function __construct(public array|Closure $handler, public array $parameters, ?string $parameter)
|
||||
{
|
||||
if ($parameter->getReturnType() != null) {
|
||||
$this->format = Kiri::getDi()->get($this->returnType($parameter));
|
||||
if ($parameter !== null) {
|
||||
$this->format = Kiri::getDi()->get($parameter);
|
||||
} else {
|
||||
$this->format = Kiri::getDi()->get(MixedFormat::class);
|
||||
}
|
||||
$this->parameters = Kiri::getDi()->getMethodParams($parameter);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ReflectionMethod $reflectionType
|
||||
* @return string
|
||||
*/
|
||||
protected function returnType(ReflectionMethod $reflectionType): string
|
||||
{
|
||||
return match ($reflectionType->getReturnType()->getName()) {
|
||||
'array' => ArrayFormat::class,
|
||||
'mixed', 'object' => MixedFormat::class,
|
||||
'int', 'string', 'bool' => OtherFormat::class,
|
||||
'void' => VoidFormat::class,
|
||||
default => ResponseFormat::class
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user