diff --git a/composer.json b/composer.json
index 90adaaf..f9b0d70 100644
--- a/composer.json
+++ b/composer.json
@@ -16,6 +16,7 @@
],
"require": {
"php": ">=8.2",
+ "ext-apcu": "*",
"php-di/php-di": "^7.0.1",
"nikic/fast-route": "^1.3",
"symfony/http-foundation": "^6.2.5",
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index 097553a..f4f4b6f 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -5,4 +5,9 @@
require_once (string) $file
+
+
+ $callable
+
+
diff --git a/psalm.xml b/psalm.xml
index 80e8554..8be119a 100644
--- a/psalm.xml
+++ b/psalm.xml
@@ -1,11 +1,11 @@
diff --git a/src/Infrastructure/WebApp/Route/HandlerResolver.php b/src/Infrastructure/WebApp/Route/HandlerResolver.php
index 7df5c40..80b9a72 100644
--- a/src/Infrastructure/WebApp/Route/HandlerResolver.php
+++ b/src/Infrastructure/WebApp/Route/HandlerResolver.php
@@ -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 $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;
}
}