Skip to content

Commit 23a6417

Browse files
committed
fix(router): handle missing MatchedRoute in isCurrentUri
Crash reproduction: `is_current_uri([HomeController::class, 'show']);` in a command
1 parent 2a078ee commit 23a6417

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

packages/router/src/UriGenerator.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@ public function isCurrentUri(array|string|MethodReflector $action, mixed ...$par
178178
{
179179
$action = $this->normalizeActionToUri($action);
180180

181+
if (! $this->container->has(MatchedRoute::class)) {
182+
return false;
183+
}
184+
181185
$matchedRoute = $this->container->get(MatchedRoute::class);
182186
$candidateUri = $this->createUri($action, ...[...$matchedRoute->params, ...$params]);
183187
$currentUri = $this->createUri([$matchedRoute->route->handler->getDeclaringClass()->getName(), $matchedRoute->route->handler->getName()]);

0 commit comments

Comments
 (0)