comparison vendor/symfony/var-dumper/Caster/RedisCaster.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 4c8ae668cc8c
children
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
18 * 18 *
19 * @author Nicolas Grekas <p@tchwork.com> 19 * @author Nicolas Grekas <p@tchwork.com>
20 */ 20 */
21 class RedisCaster 21 class RedisCaster
22 { 22 {
23 private static $serializer = array( 23 private static $serializer = [
24 \Redis::SERIALIZER_NONE => 'NONE', 24 \Redis::SERIALIZER_NONE => 'NONE',
25 \Redis::SERIALIZER_PHP => 'PHP', 25 \Redis::SERIALIZER_PHP => 'PHP',
26 2 => 'IGBINARY', // Optional Redis::SERIALIZER_IGBINARY 26 2 => 'IGBINARY', // Optional Redis::SERIALIZER_IGBINARY
27 ); 27 ];
28 28
29 public static function castRedis(\Redis $c, array $a, Stub $stub, $isNested) 29 public static function castRedis(\Redis $c, array $a, Stub $stub, $isNested)
30 { 30 {
31 $prefix = Caster::PREFIX_VIRTUAL; 31 $prefix = Caster::PREFIX_VIRTUAL;
32 32
33 if (defined('HHVM_VERSION_ID')) { 33 if (\defined('HHVM_VERSION_ID')) {
34 if (isset($a[Caster::PREFIX_PROTECTED.'serializer'])) { 34 if (isset($a[Caster::PREFIX_PROTECTED.'serializer'])) {
35 $ser = $a[Caster::PREFIX_PROTECTED.'serializer']; 35 $ser = $a[Caster::PREFIX_PROTECTED.'serializer'];
36 $a[Caster::PREFIX_PROTECTED.'serializer'] = isset(self::$serializer[$ser]) ? new ConstStub(self::$serializer[$ser], $ser) : $ser; 36 $a[Caster::PREFIX_PROTECTED.'serializer'] = isset(self::$serializer[$ser]) ? new ConstStub(self::$serializer[$ser], $ser) : $ser;
37 } 37 }
38 38
39 return $a; 39 return $a;
40 } 40 }
41 41
42 if (!$connected = $c->isConnected()) { 42 if (!$connected = $c->isConnected()) {
43 return $a + array( 43 return $a + [
44 $prefix.'isConnected' => $connected, 44 $prefix.'isConnected' => $connected,
45 ); 45 ];
46 } 46 }
47 47
48 $ser = $c->getOption(\Redis::OPT_SERIALIZER); 48 $ser = $c->getOption(\Redis::OPT_SERIALIZER);
49 $retry = defined('Redis::OPT_SCAN') ? $c->getOption(\Redis::OPT_SCAN) : 0; 49 $retry = \defined('Redis::OPT_SCAN') ? $c->getOption(\Redis::OPT_SCAN) : 0;
50 50
51 return $a + array( 51 return $a + [
52 $prefix.'isConnected' => $connected, 52 $prefix.'isConnected' => $connected,
53 $prefix.'host' => $c->getHost(), 53 $prefix.'host' => $c->getHost(),
54 $prefix.'port' => $c->getPort(), 54 $prefix.'port' => $c->getPort(),
55 $prefix.'auth' => $c->getAuth(), 55 $prefix.'auth' => $c->getAuth(),
56 $prefix.'dbNum' => $c->getDbNum(), 56 $prefix.'dbNum' => $c->getDbNum(),
57 $prefix.'timeout' => $c->getTimeout(), 57 $prefix.'timeout' => $c->getTimeout(),
58 $prefix.'persistentId' => $c->getPersistentID(), 58 $prefix.'persistentId' => $c->getPersistentID(),
59 $prefix.'options' => new EnumStub(array( 59 $prefix.'options' => new EnumStub([
60 'READ_TIMEOUT' => $c->getOption(\Redis::OPT_READ_TIMEOUT), 60 'READ_TIMEOUT' => $c->getOption(\Redis::OPT_READ_TIMEOUT),
61 'SERIALIZER' => isset(self::$serializer[$ser]) ? new ConstStub(self::$serializer[$ser], $ser) : $ser, 61 'SERIALIZER' => isset(self::$serializer[$ser]) ? new ConstStub(self::$serializer[$ser], $ser) : $ser,
62 'PREFIX' => $c->getOption(\Redis::OPT_PREFIX), 62 'PREFIX' => $c->getOption(\Redis::OPT_PREFIX),
63 'SCAN' => new ConstStub($retry ? 'RETRY' : 'NORETRY', $retry), 63 'SCAN' => new ConstStub($retry ? 'RETRY' : 'NORETRY', $retry),
64 )), 64 ]),
65 ); 65 ];
66 } 66 }
67 67
68 public static function castRedisArray(\RedisArray $c, array $a, Stub $stub, $isNested) 68 public static function castRedisArray(\RedisArray $c, array $a, Stub $stub, $isNested)
69 { 69 {
70 $prefix = Caster::PREFIX_VIRTUAL; 70 $prefix = Caster::PREFIX_VIRTUAL;
71 71
72 return $a + array( 72 return $a + [
73 $prefix.'hosts' => $c->_hosts(), 73 $prefix.'hosts' => $c->_hosts(),
74 $prefix.'function' => ClassStub::wrapCallable($c->_function()), 74 $prefix.'function' => ClassStub::wrapCallable($c->_function()),
75 ); 75 ];
76 } 76 }
77 } 77 }