From 6e521642a4cc31c6016aba3c3e8bbb205b426528 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Tue, 30 Nov 2021 15:22:32 +0100 Subject: [PATCH] fix: Typed property `RedisConnectionFactory::$redis` must not be accessed before initialization. --- .../ChillMainBundle/Redis/RedisConnectionFactory.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Redis/RedisConnectionFactory.php b/src/Bundle/ChillMainBundle/Redis/RedisConnectionFactory.php index 00b809140..6d61c408c 100644 --- a/src/Bundle/ChillMainBundle/Redis/RedisConnectionFactory.php +++ b/src/Bundle/ChillMainBundle/Redis/RedisConnectionFactory.php @@ -14,7 +14,7 @@ namespace Chill\MainBundle\Redis; use RuntimeException; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -class RedisConnectionFactory implements EventSubscriberInterface +final class RedisConnectionFactory implements EventSubscriberInterface { private string $host; @@ -29,12 +29,11 @@ class RedisConnectionFactory implements EventSubscriberInterface $this->host = $parameters['host']; $this->port = (int) $parameters['port']; $this->timeout = (int) $parameters['timeout']; + $this->redis = new ChillRedis(); } public function create() { - $this->redis = new ChillRedis(); - $result = $this->redis->connect($this->host, $this->port, $this->timeout); if (false === $result) { @@ -55,8 +54,6 @@ class RedisConnectionFactory implements EventSubscriberInterface public function onKernelFinishRequest() { - if (null !== $this->redis) { - $this->redis->close(); - } + $this->redis->close(); } }