From 70379a94132f4a21fb5f4430aa757bc7f33b51e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=9E=E6=89=AC?= <3280204+ycrao@users.noreply.github.com> Date: Thu, 25 Dec 2025 10:03:43 +0800 Subject: [PATCH 1/2] Update RouteCommand.php fix return Bad Middleware when using class string name --- flight/commands/RouteCommand.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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) { From 8b047021fef52df2444c4674f49afbc643646c97 Mon Sep 17 00:00:00 2001 From: yangzhi-rao Date: Fri, 26 Dec 2025 12:13:36 +0800 Subject: [PATCH 2/2] update route tests --- tests/commands/RouteCommandTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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