From 4753a9982456fdf946d7bc83b270e4a1c8d95372 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Thu, 5 Aug 2021 13:54:33 +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 --- HttpServer/Route/Router.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/HttpServer/Route/Router.php b/HttpServer/Route/Router.php index 1d4bb4a2..392b4e80 100644 --- a/HttpServer/Route/Router.php +++ b/HttpServer/Route/Router.php @@ -139,12 +139,12 @@ class Router extends HttpService implements RouterInterface */ private function tree($path, $handler, string $method = 'any'): Node { - [$first, $explode] = $this->split($path); + $explode = $this->split($path); if (!isset($this->nodes[$method]['/'])) { $this->nodes[$method]['/'] = $this->NodeInstance('/', 0, $method); } $parent = $this->nodes[$method]['/']; - if (!empty($first) && !empty($explode)) { + if (!empty($explode)) { $parent = $this->bindNode($parent, $explode, $method); } $parent->path = $path; @@ -162,7 +162,6 @@ class Router extends HttpService implements RouterInterface private function bindNode(Node $parent, array $explode, $method): Node { $a = 0; - var_dump($explode); foreach ($explode as $value) { ++$a; $search = $parent->findNode($value); @@ -432,13 +431,13 @@ class Router extends HttpService implements RouterInterface { $path = $this->addPrefix() . '/' . ltrim($path, '/'); if ($path === '/') { - return ['', null]; + return []; } $filter = array_filter(explode('/', $path)); if (!empty($filter)) { - return [array_shift($filter), $filter]; + return $filter; } - return ['', null]; + return []; } /**