@@ -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 }
@@ -113,6 +117,12 @@ public function read(string $class, string $defaultController = 'Home', string $
113117 $ params [$ param ->getName ()] = $ required ;
114118 }
115119
120+ // If it is the default controller, the method will not be
121+ // routed.
122+ if ($ classShortname === $ defaultController ) {
123+ $ route = 'x ' . $ route ;
124+ }
125+
116126 $ output [] = [
117127 'method ' => $ httpVerb ,
118128 'route ' => $ route ,
@@ -151,9 +161,11 @@ private function getUriByClass(string $classname): string
151161 }
152162
153163 /**
154- * Gets a route without default controller.
164+ * Gets a route for the default controller.
165+ *
166+ * @phpstan-return list<array>
155167 */
156- private function getRouteWithoutController (
168+ private function getRouteForDefaultController (
157169 string $ classShortname ,
158170 string $ defaultController ,
159171 string $ uriByClass ,
0 commit comments