File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -70,20 +70,26 @@ public function matchFromPath(string $path, string $method): Route
7070 /**
7171 * @var Route $route
7272 */
73+ $ routeMatchedButMethodNotAllowed = false ;
7374 foreach ($ this ->routes as $ route ) {
7475 if ($ route ->match ($ path ) === false ) {
7576 continue ;
7677 }
7778
7879 if (!in_array ($ method , $ route ->getMethods ())) {
79- throw new MethodNotAllowed (
80- 'Method Not Allowed : ' . $ method ,
81- self ::METHOD_NOT_ALLOWED
82- );
80+ $ routeMatchedButMethodNotAllowed = true ;
81+ continue ;
8382 }
8483 return $ route ;
8584 }
8685
86+ if ($ routeMatchedButMethodNotAllowed ) {
87+ throw new MethodNotAllowed (
88+ 'Method Not Allowed : ' . $ method ,
89+ self ::METHOD_NOT_ALLOWED
90+ );
91+ }
92+
8793 throw new RouteNotFound (
8894 'No route found for ' . $ path ,
8995 self ::NO_ROUTE
You can’t perform that action at this time.
0 commit comments