Skip to content

Commit f4a3e78

Browse files
committed
fix(routing): Extract routes even with multiple registerRoutes calls
Signed-off-by: provokateurin <[email protected]>
1 parent 3fb48b2 commit f4a3e78

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Route.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ public static function parseRoutes(string $path): array {
2929
}
3030
return include($path);
3131
} elseif (str_contains($content, "registerRoutes")) {
32-
preg_match("/registerRoutes\(.*?\\\$this,.*?(\[[^;]*)\);/s", $content, $matches);
33-
return self::includeRoutes("<?php\nreturn " . $matches[1] . ";");
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]));
3434
} else {
3535
Logger::panic("Routes", "Unknown routes.php format");
3636
}

0 commit comments

Comments
 (0)