Skip to content

Commit b26598f

Browse files
authored
Merge pull request #670 from ycrao/master
Update RouteCommand.php
2 parents bbec61b + 8b04702 commit b26598f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

flight/commands/RouteCommand.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ public function execute()
6565
if (!empty($route->middleware)) {
6666
try {
6767
$middlewares = array_map(function ($middleware) {
68-
$middleware_class_name = explode("\\", get_class($middleware));
68+
if (is_string($middleware)) {
69+
$middleware_class_name = explode("\\", $middleware);
70+
} else {
71+
$middleware_class_name = explode("\\", get_class($middleware));
72+
}
6973
return preg_match("/^class@anonymous/", end($middleware_class_name)) ? 'Anonymous' : end($middleware_class_name);
7074
}, $route->middleware);
7175
} catch (\TypeError $e) {

tests/commands/RouteCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function testGetRoutes(): void
113113
| /post | POST, OPTIONS | | No | Closure |
114114
| /delete | DELETE, OPTIONS | | No | - |
115115
| /put | PUT, OPTIONS | | No | - |
116-
| /patch | PATCH, OPTIONS | | No | Bad Middleware |
116+
| /patch | PATCH, OPTIONS | | No | SomeMiddleware |
117117
+---------+--------------------+-------+----------+----------------+
118118
output; // phpcs:ignore
119119

0 commit comments

Comments
 (0)