fix: Typed property RedisConnectionFactory::$redis must not be accessed before initialization.

This commit is contained in:
Pol Dellaiera 2021-11-30 15:22:32 +01:00
parent e76e5dd02d
commit 6e521642a4
No known key found for this signature in database
GPG Key ID: D476DFE9C67467CA

View File

@ -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();
}
}
}