diff --git a/flight/commands/RouteCommand.php b/flight/commands/RouteCommand.php index 8b5408e..bbcf52e 100644 --- a/flight/commands/RouteCommand.php +++ b/flight/commands/RouteCommand.php @@ -65,7 +65,11 @@ class RouteCommand extends AbstractBaseCommand if (!empty($route->middleware)) { try { $middlewares = array_map(function ($middleware) { - $middleware_class_name = explode("\\", get_class($middleware)); + if (is_string($middleware)) { + $middleware_class_name = explode("\\", $middleware); + } else { + $middleware_class_name = explode("\\", get_class($middleware)); + } return preg_match("/^class@anonymous/", end($middleware_class_name)) ? 'Anonymous' : end($middleware_class_name); }, $route->middleware); } catch (\TypeError $e) { diff --git a/tests/commands/RouteCommandTest.php b/tests/commands/RouteCommandTest.php index 8683871..0d2aee7 100644 --- a/tests/commands/RouteCommandTest.php +++ b/tests/commands/RouteCommandTest.php @@ -113,7 +113,7 @@ PHP; | /post | POST, OPTIONS | | No | Closure | | /delete | DELETE, OPTIONS | | No | - | | /put | PUT, OPTIONS | | No | - | - | /patch | PATCH, OPTIONS | | No | Bad Middleware | + | /patch | PATCH, OPTIONS | | No | SomeMiddleware | +---------+--------------------+-------+----------+----------------+ output; // phpcs:ignore