Failed Conditions
Pull Request — master (#10)
by Maximo
02:59
created

library/Providers/RedisProvider.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Gewaer\Providers;
4
5
use Phalcon\Di\ServiceProviderInterface;
6
use Phalcon\DiInterface;
7
use Redis;
8
use function Gewaer\Core\envValue;
9
10
class RedisProvider implements ServiceProviderInterface
11
{
12
    /**
13
     * @param DiInterface $container
14
     */
15 4
    public function register(DiInterface $container)
16
    {
17 4
        $container->setShared(
18 4
            'redis',
19
            function () {
20
                //Connect to redis
21 1
                $redis = new Redis();
22 1
                $redis->connect(envValue('REDIS_HOST', '127.0.0.1'), envValue('REDIS_PORT', 6379));
0 ignored issues
show
It seems like envValue('REDIS_PORT', 6379) can also be of type boolean and string; however, parameter $port of Redis::connect() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

22
                $redis->connect(envValue('REDIS_HOST', '127.0.0.1'), /** @scrutinizer ignore-type */ envValue('REDIS_PORT', 6379));
Loading history...
23 1
                $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);
24 1
                return $redis;
25 4
            }
26
        );
27 4
    }
28
}
29