From 7732be0faf023ce5337b9008c88b2275ef678682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Mon, 6 Sep 2021 18:57:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- http-helper/Route/Router.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/http-helper/Route/Router.php b/http-helper/Route/Router.php index 915995de..6125058c 100644 --- a/http-helper/Route/Router.php +++ b/http-helper/Route/Router.php @@ -329,6 +329,7 @@ class Router extends HttpService implements RouterInterface * @return Closure|array|null * @throws NotFindClassException * @throws ReflectionException + * @throws Exception */ private function getMiddlewareInstance($value): null|Closure|array { @@ -387,17 +388,17 @@ class Router extends HttpService implements RouterInterface } /** - * @param array|null $explode + * @param string|null $explode * @return Node|null * 查找指定路由 * @throws Exception */ - public function tree_search(?array $explode): ?Node + public function tree_search(?string $explode): ?Node { if (empty($this->nodes)) { return null; } - $parent = $this->nodes[array_shift($explode)] ?? null; + return $this->nodes[$explode] ?? null; if (!($parent instanceof Node)) { return null; } @@ -506,7 +507,7 @@ class Router extends HttpService implements RouterInterface // } // } else { // } - $node = $this->tree_search([$uri->getPath()]); + $node = $this->tree_search($uri->getPath()); if (!($node instanceof Node)) { return null; }