File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,10 @@ public function collect(): Generator
3838 $ routes = $ this ->routeCollection ->getRoutes ($ method );
3939
4040 foreach ($ routes as $ route => $ handler ) {
41+ // The route key should be a string, but it is stored as an array key,
42+ // it might be an integer.
43+ $ route = (string ) $ route ;
44+
4145 if (is_string ($ handler ) || $ handler instanceof Closure) {
4246 if ($ handler instanceof Closure) {
4347 $ view = $ this ->routeCollection ->getRoutesOptions ($ route , $ method )['view ' ] ?? false ;
Original file line number Diff line number Diff line change @@ -50,8 +50,10 @@ public function testCollect(): void
5050 {
5151 $ routes = $ this ->createRouteCollection ();
5252 $ routes ->get ('journals ' , 'Blogs ' );
53+ $ routes ->get ('100 ' , 'Home::index ' );
5354 $ routes ->get ('product/(:num) ' , 'Catalog::productLookupByID/$1 ' );
5455 $ routes ->get ('feed ' , static fn () => 'A Closure route. ' );
56+ $ routes ->get ('200 ' , static fn () => 'A Closure route. ' );
5557 $ routes ->view ('about ' , 'pages/about ' );
5658
5759 $ collector = new DefinedRouteCollector ($ routes );
@@ -69,6 +71,12 @@ public function testCollect(): void
6971 'name ' => 'journals ' ,
7072 'handler ' => '\App\Controllers\Blogs ' ,
7173 ],
74+ [
75+ 'method ' => 'GET ' ,
76+ 'route ' => '100 ' ,
77+ 'name ' => '100 ' ,
78+ 'handler ' => '\App\Controllers\Home::index ' ,
79+ ],
7280 [
7381 'method ' => 'GET ' ,
7482 'route ' => 'product/([0-9]+) ' ,
@@ -81,6 +89,12 @@ public function testCollect(): void
8189 'name ' => 'feed ' ,
8290 'handler ' => '(Closure) ' ,
8391 ],
92+ [
93+ 'method ' => 'GET ' ,
94+ 'route ' => '200 ' ,
95+ 'name ' => '200 ' ,
96+ 'handler ' => '(Closure) ' ,
97+ ],
8498 [
8599 'method ' => 'GET ' ,
86100 'route ' => 'about ' ,
You can’t perform that action at this time.
0 commit comments