2222 */
2323class RedisCaster
2424{
25- private static $ serializer = [
25+ private const SERIALIZERS = [
2626 \Redis::SERIALIZER_NONE => 'NONE ' ,
2727 \Redis::SERIALIZER_PHP => 'PHP ' ,
2828 2 => 'IGBINARY ' , // Optional Redis::SERIALIZER_IGBINARY
2929 ];
3030
31- private static $ mode = [
31+ private const MODES = [
3232 \Redis::ATOMIC => 'ATOMIC ' ,
3333 \Redis::MULTI => 'MULTI ' ,
3434 \Redis::PIPELINE => 'PIPELINE ' ,
3535 ];
3636
37- private static $ compression = [
37+ private const COMPRESSION_MODES = [
3838 0 => 'NONE ' , // Redis::COMPRESSION_NONE
3939 1 => 'LZF ' , // Redis::COMPRESSION_LZF
4040 ];
4141
42- private static $ failover = [
42+ private const FAILOVER_OPTIONS = [
4343 \RedisCluster::FAILOVER_NONE => 'NONE ' ,
4444 \RedisCluster::FAILOVER_ERROR => 'ERROR ' ,
4545 \RedisCluster::FAILOVER_DISTRIBUTE => 'DISTRIBUTE ' ,
@@ -63,7 +63,7 @@ public static function castRedis(\Redis $c, array $a, Stub $stub, $isNested)
6363 $ prefix .'host ' => $ c ->getHost (),
6464 $ prefix .'port ' => $ c ->getPort (),
6565 $ prefix .'auth ' => $ c ->getAuth (),
66- $ prefix .'mode ' => isset (self ::$ mode [$ mode ]) ? new ConstStub (self ::$ mode [$ mode ], $ mode ) : $ mode ,
66+ $ prefix .'mode ' => isset (self ::MODES [$ mode ]) ? new ConstStub (self ::MODES [$ mode ], $ mode ) : $ mode ,
6767 $ prefix .'dbNum ' => $ c ->getDbNum (),
6868 $ prefix .'timeout ' => $ c ->getTimeout (),
6969 $ prefix .'lastError ' => $ c ->getLastError (),
@@ -95,7 +95,7 @@ public static function castRedisCluster(\RedisCluster $c, array $a, Stub $stub,
9595 $ prefix .'mode ' => new ConstStub ($ c ->getMode () ? 'MULTI ' : 'ATOMIC ' , $ c ->getMode ()),
9696 $ prefix .'lastError ' => $ c ->getLastError (),
9797 $ prefix .'options ' => self ::getRedisOptions ($ c , [
98- 'SLAVE_FAILOVER ' => isset (self ::$ failover [$ failover ]) ? new ConstStub (self ::$ failover [$ failover ], $ failover ) : $ failover ,
98+ 'SLAVE_FAILOVER ' => isset (self ::FAILOVER_OPTIONS [$ failover ]) ? new ConstStub (self ::FAILOVER_OPTIONS [$ failover ], $ failover ) : $ failover ,
9999 ]),
100100 ];
101101
@@ -110,23 +110,23 @@ private static function getRedisOptions($redis, array $options = []): EnumStub
110110 $ serializer = $ redis ->getOption (\Redis::OPT_SERIALIZER );
111111 if (\is_array ($ serializer )) {
112112 foreach ($ serializer as &$ v ) {
113- if (isset (self ::$ serializer [$ v ])) {
114- $ v = new ConstStub (self ::$ serializer [$ v ], $ v );
113+ if (isset (self ::SERIALIZERS [$ v ])) {
114+ $ v = new ConstStub (self ::SERIALIZERS [$ v ], $ v );
115115 }
116116 }
117- } elseif (isset (self ::$ serializer [$ serializer ])) {
118- $ serializer = new ConstStub (self ::$ serializer [$ serializer ], $ serializer );
117+ } elseif (isset (self ::SERIALIZERS [$ serializer ])) {
118+ $ serializer = new ConstStub (self ::SERIALIZERS [$ serializer ], $ serializer );
119119 }
120120
121121 $ compression = \defined ('Redis::OPT_COMPRESSION ' ) ? $ redis ->getOption (\Redis::OPT_COMPRESSION ) : 0 ;
122122 if (\is_array ($ compression )) {
123123 foreach ($ compression as &$ v ) {
124- if (isset (self ::$ compression [$ v ])) {
125- $ v = new ConstStub (self ::$ compression [$ v ], $ v );
124+ if (isset (self ::COMPRESSION_MODES [$ v ])) {
125+ $ v = new ConstStub (self ::COMPRESSION_MODES [$ v ], $ v );
126126 }
127127 }
128- } elseif (isset (self ::$ compression [$ compression ])) {
129- $ compression = new ConstStub (self ::$ compression [$ compression ], $ compression );
128+ } elseif (isset (self ::COMPRESSION_MODES [$ compression ])) {
129+ $ compression = new ConstStub (self ::COMPRESSION_MODES [$ compression ], $ compression );
130130 }
131131
132132 $ retry = \defined ('Redis::OPT_SCAN ' ) ? $ redis ->getOption (\Redis::OPT_SCAN ) : 0 ;
0 commit comments