fix phpstan errors

This commit is contained in:
lubiana 2022-11-07 17:16:33 +01:00
parent dff0cc92e0
commit fe112f872f
4 changed files with 15 additions and 6 deletions

View file

@ -32,10 +32,12 @@ final class DispatcherFactory
private function getListeners(bool $cached = false): array
{
if ($cached === true && file_exists(self::CACHE_FILE)) {
$data = file_get_contents(self::CACHE_FILE);
if ($data === false) {
return [];
}
/** @var Listener[] $listeners */
$listeners = unserialize(
file_get_contents(self::CACHE_FILE)
); //@phpstan-ignore-line
$listeners = unserialize($data);
return $listeners;
}

View file

@ -68,7 +68,13 @@ final class Finder
}
if ($this->cached === true && file_exists(self::CACHE_FILE)) {
$this->classNames = unserialize(file_get_contents(self::CACHE_FILE));
$data = file_get_contents(self::CACHE_FILE);
if ($data === false) {
return;
}
/** @var class-string[] $result */
$result = unserialize($data);
$this->classNames = $result;
return;
}

View file

@ -5,7 +5,7 @@ namespace Lubian\AttributeMagic\Infrastructure\Route;
final class Handler
{
/**
* @param non-empty-string $path
* @param string $path
* @param non-empty-string $handlerClass
* @param non-empty-string $handlerMethod
*/

View file

@ -18,9 +18,10 @@ final class CachedResponse
{
$response = new Response('lol');
$serialized = serialize($response);
/** @var Response|null $response */
$response = unserialize($serialized);
$event->response = $response;
// $event->stopped = true;
$event->stopped = true;
}
#[AsListener(RequestEvent::class, 99)]