fix psalm issues
This commit is contained in:
parent
224925e56b
commit
7fa412493e
4 changed files with 33 additions and 6 deletions
|
@ -46,8 +46,7 @@ final readonly class HandlerResolver
|
|||
);
|
||||
|
||||
if ($routeInfo[0] === \FastRoute\Dispatcher::NOT_FOUND) {
|
||||
$event->response = new Response('Not Found', 404);
|
||||
$event->stopped = true;
|
||||
$this->notFound($event);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -57,12 +56,34 @@ final readonly class HandlerResolver
|
|||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
!is_array($routeInfo[1])
|
||||
|| count($routeInfo[1]) !== 2
|
||||
|| !is_string($routeInfo[1][0])
|
||||
|| $routeInfo[1][0] === ''
|
||||
|| !is_string($routeInfo[1][1])
|
||||
|| $routeInfo[1][1] === ''
|
||||
) {
|
||||
$this->notFound($event);
|
||||
return;
|
||||
}
|
||||
|
||||
$event->handler = new Handler(
|
||||
HttpMethod::from($event->request->getMethod()),
|
||||
$event->request->getPathInfo(),
|
||||
...$routeInfo[1],
|
||||
$routeInfo[1][0],
|
||||
$routeInfo[1][1],
|
||||
);
|
||||
|
||||
$event->request->attributes->add($routeInfo[2]);
|
||||
/** @var array<array-key, mixed> $args */
|
||||
$args = $routeInfo[2];
|
||||
|
||||
$event->request->attributes->add($args);
|
||||
}
|
||||
|
||||
private function notFound(RequestEvent $event): void
|
||||
{
|
||||
$event->response = new Response('Not Found', 404);
|
||||
$event->stopped = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue