From 73a71267f50c96e52423854b28883959712eef07 Mon Sep 17 00:00:00 2001 From: xl Date: Fri, 17 Nov 2023 00:02:41 +0800 Subject: [PATCH] eee --- src/RouterCollector.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/RouterCollector.php b/src/RouterCollector.php index e2cd0f1..a633d99 100644 --- a/src/RouterCollector.php +++ b/src/RouterCollector.php @@ -136,7 +136,7 @@ class RouterCollector implements \ArrayAccess, \IteratorAggregate public function addRoute(array $method, string $route, string|array|Closure $closure): void { try { - $route = $this->_splicing_routing($route); + $route = $this->_splicing_routing($route); if ($closure instanceof Closure) { $handler = $this->interpreter->addRouteByClosure($closure); } else { @@ -175,15 +175,13 @@ class RouterCollector implements \ArrayAccess, \IteratorAggregate private function resolve(string|array $closure, ControllerInterpreter $interpreter): Handler { if (is_array($closure)) { - [$class, $method] = $closure; - } else { - if (!str_contains($closure, '@')) { - $closure .= '@'; - } - [$className, $method] = explode('@', $closure); - - $class = $this->container->get($this->resetName($className)); + return $interpreter->addRouteByString(... $closure); } + if (!str_contains($closure, '@')) { + $closure .= '@'; + } + [$className, $method] = explode('@', $closure); + $class = $this->container->get($this->resetName($className)); return $interpreter->addRouteByString($class, $method); }