@@ -65,8 +65,9 @@ public function read(string $class, string $defaultController = 'Home', string $
6565 // Remove HTTP verb prefix.
6666 $ methodInUri = lcfirst (substr ($ methodName , strlen ($ httpVerb )));
6767
68+ // Check if it is the default method.
6869 if ($ methodInUri === $ defaultMethod ) {
69- $ routeWithoutController = $ this ->getRouteWithoutController (
70+ $ routeForDefaultController = $ this ->getRouteForDefaultController (
7071 $ classShortname ,
7172 $ defaultController ,
7273 $ classInUri ,
@@ -75,8 +76,11 @@ public function read(string $class, string $defaultController = 'Home', string $
7576 $ httpVerb
7677 );
7778
78- if ($ routeWithoutController !== []) {
79- $ output = [...$ output , ...$ routeWithoutController ];
79+ if ($ routeForDefaultController !== []) {
80+ // The controller is the default controller. It only
81+ // has a route for the default method. Other methods
82+ // will not be routed even if they exist.
83+ $ output = [...$ output , ...$ routeForDefaultController ];
8084
8185 continue ;
8286 }
@@ -151,9 +155,11 @@ private function getUriByClass(string $classname): string
151155 }
152156
153157 /**
154- * Gets a route without default controller.
158+ * Gets a route for the default controller.
159+ *
160+ * @phpstan-return list<array>
155161 */
156- private function getRouteWithoutController (
162+ private function getRouteForDefaultController (
157163 string $ classShortname ,
158164 string $ defaultController ,
159165 string $ uriByClass ,
0 commit comments