Skip to content

Commit 258e1fc

Browse files
update file
1 parent 0d7278c commit 258e1fc

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/libraries/Http/Router.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,8 @@ private function resolve($callback)
245245

246246
return match (true) {
247247
is_callable($callback) => $this->callCallback($callback), // if it's callable - just execute
248-
is_array($callback) => $this->invokeRouteWithMethodCall(), // If it's an array, assume [ControllerClass, MethodName].
249-
is_string($callback) => $this->invokeRouteWithSingleCallback($callback) //if it's just a Myclass::class
248+
is_array($callback) => $this->invokeRouteWithMethodCall(), // If it's an array, assume [ControllerClass, MethodName].
249+
is_string($callback) => $this->invokeRouteWithSingleCallback($callback) //if it's just a Myclass::class
250250
};
251251
}
252252

@@ -353,7 +353,7 @@ private function invokeRouteWithMethodCall(): mixed
353353
*/
354354
private function extractRegex(string $method, string $uri)
355355
{
356-
foreach (static::$routeMap[$method] as $route => $handler) {
356+
foreach (static::$routeMap[$method] ?? [] as $route => $handler) {
357357
$pattern = '~^' . $this->compileRoute($route) . '$~';
358358
if (preg_match($pattern, $uri, $params)) {
359359
$params = array_filter($params, 'is_string', ARRAY_FILTER_USE_KEY);
@@ -414,7 +414,7 @@ public function baseUrl(string $path = '/'): string
414414

415415
return "{$baseUrl}/{$path}";
416416
}
417-
417+
418418
/**
419419
* Renders the error view based on the specified HTTP error code.
420420
*/

0 commit comments

Comments
 (0)