@@ -79,15 +79,15 @@ private function convertRouteToAltoRouterUri(Route $route, AltoRouter $altoRoute
7979 {
8080 $ output = $ route ->getUri ();
8181
82- preg_match_all ('/{\s*([a-zA-Z0-9]+\??)\s*}/s ' , ( string ) $ route ->getUri (), $ matches );
82+ preg_match_all ('/{\s*([a-zA-Z0-9]+\??)\s*}/s ' , $ route ->getUri (), $ matches );
8383
8484 $ paramConstraints = $ route ->getParamConstraints ();
8585
8686 for ($ i = 0 ; $ i < count ($ matches [0 ]); $ i ++) {
8787 $ match = $ matches [0 ][$ i ];
8888 $ paramKey = $ matches [1 ][$ i ];
8989
90- $ optional = str_ends_with ($ paramKey , '? ' ) ;
90+ $ optional = substr ($ paramKey , - 1 ) === '? ' ;
9191 $ paramKey = trim ($ paramKey , '? ' );
9292
9393 $ regex = $ paramConstraints [$ paramKey ] ?? null ;
@@ -109,7 +109,7 @@ private function convertRouteToAltoRouterUri(Route $route, AltoRouter $altoRoute
109109 $ output = str_replace ($ match , $ replacement , $ output );
110110 }
111111
112- return ltrim (( string ) $ output , ' / ' );
112+ return ltrim ($ output , ' / ' );
113113 }
114114
115115 public function map (array $ verbs , string $ uri , $ callback ): Route
@@ -180,7 +180,9 @@ protected function handle($route, $request, $params)
180180
181181 // Apply all the base middleware and trigger the route handler as the last in the chain
182182 $ middlewares = array_merge ($ this ->baseMiddleware , [
183- fn ($ request ) => $ route ->handle ($ request , $ params ),
183+ function ($ request ) use ($ route , $ params ) {
184+ return $ route ->handle ($ request , $ params );
185+ },
184186 ]);
185187
186188 // Create and process the dispatcher
@@ -197,7 +199,9 @@ protected function handle($route, $request, $params)
197199
198200 public function has (string $ name )
199201 {
200- $ routes = array_filter ($ this ->routes , fn ($ route ) => $ route ->getName () === $ name );
202+ $ routes = array_filter ($ this ->routes , function ($ route ) use ($ name ) {
203+ return $ route ->getName () === $ name ;
204+ });
201205
202206 return count ($ routes ) > 0 ;
203207 }
@@ -223,7 +227,7 @@ public function url(string $name, $params = [])
223227 $ regex = $ paramConstraints [$ key ] ?? false ;
224228
225229 if ($ regex ) {
226- if (!preg_match ('/ ' . $ regex . '/ ' , ( string ) $ value )) {
230+ if (!preg_match ('/ ' . $ regex . '/ ' , $ value )) {
227231 throw new RouteParamFailedConstraintException (
228232 'Value ` ' . $ value . '` for param ` ' . $ key . '` fails constraint ` ' . $ regex . '` '
229233 );
@@ -234,7 +238,7 @@ public function url(string $name, $params = [])
234238
235239 try {
236240 return $ this ->altoRouter ->generate ($ name , $ params );
237- } catch (\Exception ) {
241+ } catch (\Exception $ e ) {
238242 throw new NamedRouteNotFoundException ($ name );
239243 }
240244 }
0 commit comments