getReflectionClass($class::class); } return $this->resolveMethod($class, $method, $reflection); } /** * @param Closure $method * @return Handler * @throws ReflectionException */ public function addRouteByClosure(Closure $method): Handler { $reflection = \Kiri::getDi()->getFunctionParams($method); return new Handler($method, $reflection); } /** * @param object $class * @param string|ReflectionMethod $method * @param ReflectionClass|null $reflection * @return Handler * @throws ReflectionException */ public function addRouteByObject(object $class, string|ReflectionMethod $method, ?ReflectionClass $reflection = null): Handler { if (is_null($reflection)) { $reflection = \Kiri::getDi()->getReflectionClass($class::class); } return $this->resolveMethod($class, $method, $reflection); } /** * @param object $class * @param string|ReflectionMethod $reflectionMethod * @param ReflectionClass $reflectionClass * @return Handler * @throws ReflectionException */ public function resolveMethod(object $class, string|\ReflectionMethod $reflectionMethod, ReflectionClass $reflectionClass): Handler { if (is_string($reflectionMethod)) { $reflectionMethod = $reflectionClass->getMethod($reflectionMethod); } $container = \Kiri::getDi(); $parameters = $container->getMethodParams($reflectionMethod); return new Handler([$class, $reflectionMethod->getName()], $parameters); } }