@@ -22,18 +22,19 @@ public function __construct(
2222
2323 public static function parseRoutes (string $ path ): array {
2424 $ content = file_get_contents ($ path );
25- if (str_contains ($ content , " return " )) {
26- if (str_contains ($ content , "\ $this " )) {
27- preg_match (" /return ([^;]*);/ " , $ content , $ matches );
28- return self ::includeRoutes ("<?php \nreturn " . $ matches [1 ] . " ; " );
25+ if (str_contains ($ content , ' return ' )) {
26+ if (str_contains ($ content , ' $this ' )) {
27+ preg_match (' /return ([^;]*);/ ' , $ content , $ matches );
28+ return self ::includeRoutes ("<?php \nreturn $ { matches[1 ]} ; " );
2929 }
3030 return include ($ path );
31- } elseif (str_contains ($ content , "registerRoutes " )) {
32- preg_match_all ("/registerRoutes\(.*? \\\$this,.*?(\[[^;]*)\);/s " , $ content , $ matches );
33- return array_merge (...array_map (fn (string $ match ) => self ::includeRoutes ("<?php \nreturn " . $ match . "; " ), $ matches [1 ]));
34- } else {
35- Logger::panic ("Routes " , "Unknown routes.php format " );
31+ } elseif (str_contains ($ content , 'registerRoutes ' )) {
32+ preg_match_all ('/registerRoutes\(.*?\$this,.*?(\[[^;]*)\);/s ' , $ content , $ matches );
33+ return array_merge (...array_map (fn (string $ match ) => self ::includeRoutes ("<?php \nreturn $ match; " ), $ matches [1 ]));
3634 }
35+
36+ Logger::warning ('Routes ' , 'Unknown routes.php format ' );
37+ return [];
3738 }
3839
3940 private static function includeRoutes (string $ code ): array {
0 commit comments