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 private function getListeners(bool $cached = false): array
{ {
if ($cached === true && file_exists(self::CACHE_FILE)) { if ($cached === true && file_exists(self::CACHE_FILE)) {
$data = file_get_contents(self::CACHE_FILE);
if ($data === false) {
return [];
}
/** @var Listener[] $listeners */ /** @var Listener[] $listeners */
$listeners = unserialize( $listeners = unserialize($data);
file_get_contents(self::CACHE_FILE)
); //@phpstan-ignore-line
return $listeners; return $listeners;
} }

View file

@ -68,7 +68,13 @@ final class Finder
} }
if ($this->cached === true && file_exists(self::CACHE_FILE)) { 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; return;
} }

View file

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

View file

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