From 41bd59591ff4dd0d229f3233404bbc0c13562c93 Mon Sep 17 00:00:00 2001 From: xl Date: Mon, 12 Jun 2023 17:49:03 +0800 Subject: [PATCH] qqq --- src/RouterCollector.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/RouterCollector.php b/src/RouterCollector.php index 147a7ed..3d88ad2 100644 --- a/src/RouterCollector.php +++ b/src/RouterCollector.php @@ -49,7 +49,7 @@ class RouterCollector implements \ArrayAccess, \IteratorAggregate $this->methods = new HashMap(); $this->default = new HashMap(); - $this->default->put('handler', new Handler([di(NotFoundController::class), 'fail'], [])); + $this->default->put(':_handler', new Handler([di(NotFoundController::class), 'fail'], [])); } @@ -158,10 +158,10 @@ class RouterCollector implements \ArrayAccess, \IteratorAggregate if ($hashMap->has($item)) { $hashMap = $hashMap->get($item); } else { - $hashMap->put($path, $hashMap = new HashMap()); + $hashMap->put($item, $hashMap = new HashMap()); } } - $hashMap->put('handler', $handler); + $hashMap->put(':_handler', $handler); $this->registerMiddleware($handler->getClass(), $handler->getMethod()); } @@ -214,24 +214,24 @@ class RouterCollector implements \ArrayAccess, \IteratorAggregate { $parent = $this->methods->get($method); if ($parent === null) { - return $this->default->get('handler'); + return $this->default->get(':_handler'); } if ($method === 'OPTIONS') { $path = '/*'; } $lists = str_split($path, 4); - foreach ($lists as $list) { - $parent = $parent->get($list); + foreach ($lists as $item) { + $parent = $parent->get($item); if ($parent === null) { - return $this->default->get('handler'); + return $this->default->get(':_handler'); } } // /** @var HashMap $parent */ // $parent = $parent->get($path, $this->default); - return $parent->get('handler'); + return $parent->get(':_handler'); }