From 451441e6bd3a24e5a101a70ef7845bf562cebd72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Wed, 19 Apr 2023 23:11:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/RouterCollector.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/RouterCollector.php b/src/RouterCollector.php index 68eca25..01e8011 100644 --- a/src/RouterCollector.php +++ b/src/RouterCollector.php @@ -27,6 +27,9 @@ class RouterCollector implements \ArrayAccess, \IteratorAggregate private array $_item = []; + private array $dump = []; + + public array $groupTack = []; @@ -42,6 +45,15 @@ class RouterCollector implements \ArrayAccess, \IteratorAggregate } + /** + * @return array + */ + public function getDump(): array + { + return $this->dump; + } + + /** * @return Traversable */ @@ -71,6 +83,12 @@ class RouterCollector implements \ArrayAccess, \IteratorAggregate if ($value instanceof RequestMethod) { $value = $value->getString(); } + if (is_array($closure)) { + $closure[0] = is_object($closure[0]) ? get_class($closure[0]) : $closure; + } else if (is_string($closure)) { + $closure = explode('@', $closure); + } + $this->dump[$value][$route] = $closure instanceof Closure ? 'Closure' : $closure; $this->register($route, $value, $handler); } } catch (Throwable $throwable) {