@@ -60,8 +60,10 @@ final class AutoRouterImproved implements AutoRouterInterface
6060
6161 /**
6262 * HTTP verb for the request.
63+ *
64+ * @deprecated No longer used.
6365 */
64- private string $ httpVerb ;
66+ private string $ httpVerb ; // @phpstan-ignore-line
6567
6668 /**
6769 * The namespace for controllers.
@@ -74,15 +76,17 @@ final class AutoRouterImproved implements AutoRouterInterface
7476 private string $ defaultController ;
7577
7678 /**
77- * The name of the default method
79+ * The name of the default method without HTTP verb prefix.
7880 */
7981 private string $ defaultMethod ;
8082
8183 /**
8284 * @param class-string[] $protectedControllers
8385 * @param string $defaultController Short classname
86+ *
87+ * @deprecated $httpVerb is deprecated. No longer used.
8488 */
85- public function __construct (
89+ public function __construct (// @phpstan-ignore-line
8690 array $ protectedControllers ,
8791 string $ namespace ,
8892 string $ defaultController ,
@@ -93,22 +97,23 @@ public function __construct(
9397 $ this ->protectedControllers = $ protectedControllers ;
9498 $ this ->namespace = rtrim ($ namespace , '\\' ) . '\\' ;
9599 $ this ->translateURIDashes = $ translateURIDashes ;
96- $ this ->httpVerb = $ httpVerb ;
97100 $ this ->defaultController = $ defaultController ;
98- $ this ->defaultMethod = $ httpVerb . ucfirst ( $ defaultMethod) ;
101+ $ this ->defaultMethod = $ defaultMethod ;
99102
100103 // Set the default values
101104 $ this ->controller = $ this ->defaultController ;
102- $ this ->method = $ this ->defaultMethod ;
103105 }
104106
105107 /**
106108 * Finds controller, method and params from the URI.
107109 *
108110 * @return array [directory_name, controller_name, controller_method, params]
109111 */
110- public function getRoute (string $ uri ): array
112+ public function getRoute (string $ uri, string $ httpVerb ): array
111113 {
114+ $ defaultMethod = $ httpVerb . ucfirst ($ this ->defaultMethod );
115+ $ this ->method = $ defaultMethod ;
116+
112117 $ segments = explode ('/ ' , $ uri );
113118
114119 // WARNING: Directories get shifted out of the segments array.
@@ -144,10 +149,10 @@ public function getRoute(string $uri): array
144149 $ methodSegment = $ this ->translateURIDashes (array_shift ($ nonDirSegments ));
145150
146151 // Prefix HTTP verb
147- $ this ->method = $ this -> httpVerb . ucfirst ($ methodSegment );
152+ $ this ->method = $ httpVerb . ucfirst ($ methodSegment );
148153
149154 // Prevent access to default method path
150- if (strtolower ($ this ->method ) === strtolower ($ this -> defaultMethod )) {
155+ if (strtolower ($ this ->method ) === strtolower ($ defaultMethod )) {
151156 throw new PageNotFoundException (
152157 'Cannot access the default method " ' . $ this ->method . '" with the method name URI path. '
153158 );
0 commit comments