fix psalm issues
This commit is contained in:
parent
224925e56b
commit
7fa412493e
4 changed files with 33 additions and 6 deletions
|
@ -16,6 +16,7 @@
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=8.2",
|
"php": ">=8.2",
|
||||||
|
"ext-apcu": "*",
|
||||||
"php-di/php-di": "^7.0.1",
|
"php-di/php-di": "^7.0.1",
|
||||||
"nikic/fast-route": "^1.3",
|
"nikic/fast-route": "^1.3",
|
||||||
"symfony/http-foundation": "^6.2.5",
|
"symfony/http-foundation": "^6.2.5",
|
||||||
|
|
|
@ -5,4 +5,9 @@
|
||||||
<code>require_once (string) $file</code>
|
<code>require_once (string) $file</code>
|
||||||
</UnresolvableInclude>
|
</UnresolvableInclude>
|
||||||
</file>
|
</file>
|
||||||
|
<file src="src/Infrastructure/functions.php">
|
||||||
|
<MixedArgumentTypeCoercion>
|
||||||
|
<code>$callable</code>
|
||||||
|
</MixedArgumentTypeCoercion>
|
||||||
|
</file>
|
||||||
</files>
|
</files>
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<psalm
|
<psalm
|
||||||
errorLevel="2"
|
errorLevel="1"
|
||||||
resolveFromConfigFile="true"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns="https://getpsalm.org/schema/config"
|
xmlns="https://getpsalm.org/schema/config"
|
||||||
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
|
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
|
||||||
findUnusedBaselineEntry="true"
|
findUnusedBaselineEntry="true"
|
||||||
|
findUnusedCode="false"
|
||||||
errorBaseline="psalm-baseline.xml"
|
errorBaseline="psalm-baseline.xml"
|
||||||
>
|
>
|
||||||
<projectFiles>
|
<projectFiles>
|
||||||
|
|
|
@ -46,8 +46,7 @@ final readonly class HandlerResolver
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($routeInfo[0] === \FastRoute\Dispatcher::NOT_FOUND) {
|
if ($routeInfo[0] === \FastRoute\Dispatcher::NOT_FOUND) {
|
||||||
$event->response = new Response('Not Found', 404);
|
$this->notFound($event);
|
||||||
$event->stopped = true;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,12 +56,34 @@ final readonly class HandlerResolver
|
||||||
return;
|
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(
|
$event->handler = new Handler(
|
||||||
HttpMethod::from($event->request->getMethod()),
|
HttpMethod::from($event->request->getMethod()),
|
||||||
$event->request->getPathInfo(),
|
$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…
Reference in a new issue