diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 822cb1a24c932178f2a64a2167d5cec35966193d..4ae0e40f19fc2f3fc53c93d344694745f3282b4c 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,4 +1,3 @@ parameters: level: max checkMissingIterableValueType: false - treatPhpDocTypesAsCertain: false diff --git a/src/Batch/PhpRedisBatchStorage.php b/src/Batch/PhpRedisBatchStorage.php index 5cd9eb167d46b9133110300c5bcd30cf1a7eec86..f2829a780c41d5164d41188c03dbd58fb1884ed9 100644 --- a/src/Batch/PhpRedisBatchStorage.php +++ b/src/Batch/PhpRedisBatchStorage.php @@ -14,51 +14,23 @@ use Symfony\Component\HttpFoundation\Session\SessionInterface; */ class PhpRedisBatchStorage implements BatchStorageInterface { - public const TTL = 864000; + public const TTL = 864_000; use RedisPrefixTrait; - /** - * The redis client factory. - * - * @var \Drupal\redis\ClientFactory - */ - protected $clientFactory; - - /** - * The CSRF token generator. - * - * @var \Drupal\Core\Access\CsrfTokenGenerator - */ - protected $csrfToken; - - /** - * The serialization class to use. - * - * @var \Drupal\Component\Serialization\SerializationInterface - */ - protected $serializer; - - /** - * The session. - * - * @var \Symfony\Component\HttpFoundation\Session\SessionInterface - */ - protected $session; - /** * The redis client. * * @var \Redis */ - private $client; + private \Redis $client; /** * Constructs a PhpRedisBatchStorage object. * - * @param \Drupal\redis\ClientFactory $client_factory + * @param \Drupal\redis\ClientFactory $clientFactory * The redis client. - * @param \Drupal\Core\Access\CsrfTokenGenerator $csrf_token + * @param \Drupal\Core\Access\CsrfTokenGenerator $csrfToken * The CSRF token generator. * @param \Drupal\Component\Serialization\SerializationInterface $serializer * The serialization class to use. @@ -66,15 +38,11 @@ class PhpRedisBatchStorage implements BatchStorageInterface { * The session. */ public function __construct( - ClientFactory $client_factory, - CsrfTokenGenerator $csrf_token, - SerializationInterface $serializer, - SessionInterface $session + protected readonly ClientFactory $clientFactory, + protected readonly CsrfTokenGenerator $csrfToken, + protected readonly SerializationInterface $serializer, + protected readonly SessionInterface $session ) { - $this->clientFactory = $client_factory; - $this->session = $session; - $this->csrfToken = $csrf_token; - $this->serializer = $serializer; } /** @@ -82,7 +50,7 @@ class PhpRedisBatchStorage implements BatchStorageInterface { * * @phpstan-return array|false */ - public function load($id) { + public function load($id): bool|array { $this->session->start(); $hash = $this->getClient()->hGetAll($this->getPrefix() . ':' . $id); if ($hash && $this->csrfToken->validate($hash['token'], (string) $id)) { @@ -151,7 +119,7 @@ class PhpRedisBatchStorage implements BatchStorageInterface { * The redis client. */ private function getClient(): \Redis { - if (!$this->client) { + if (!isset($this->client)) { $this->client = $this->clientFactory::getClient(); } return $this->client;