Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c1e5035

Browse filesBrowse files
committed
[VarDumper] Add Relay support
1 parent 327969e commit c1e5035
Copy full SHA for c1e5035

File tree

Expand file treeCollapse file tree

4 files changed

+30
-17
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+30
-17
lines changed

‎src/Symfony/Component/VarDumper/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CHANGELOG
66

77
* Add caster for `WeakMap`
88
* Add support of named arguments to `dd()` and `dump()` to display the argument name
9+
* Add support for `Relay\Relay`
910

1011
6.2
1112
---

‎src/Symfony/Component/VarDumper/Caster/RedisCaster.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Caster/RedisCaster.php
+12-11Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\VarDumper\Caster;
1313

14+
use Relay\Relay;
1415
use Symfony\Component\VarDumper\Cloner\Stub;
1516

1617
/**
@@ -23,15 +24,15 @@
2324
class RedisCaster
2425
{
2526
private const SERIALIZERS = [
26-
\Redis::SERIALIZER_NONE => 'NONE',
27-
\Redis::SERIALIZER_PHP => 'PHP',
27+
0 => 'NONE', // Redis::SERIALIZER_NONE
28+
1 => 'PHP', // Redis::SERIALIZER_PHP
2829
2 => 'IGBINARY', // Optional Redis::SERIALIZER_IGBINARY
2930
];
3031

3132
private const MODES = [
32-
\Redis::ATOMIC => 'ATOMIC',
33-
\Redis::MULTI => 'MULTI',
34-
\Redis::PIPELINE => 'PIPELINE',
33+
0 => 'ATOMIC', // Redis::ATOMIC
34+
1 => 'MULTI', // Redis::MULTI
35+
2 => 'PIPELINE', // Redis::PIPELINE
3536
];
3637

3738
private const COMPRESSION_MODES = [
@@ -46,7 +47,7 @@ class RedisCaster
4647
\RedisCluster::FAILOVER_DISTRIBUTE_SLAVES => 'DISTRIBUTE_SLAVES',
4748
];
4849

49-
public static function castRedis(\Redis $c, array $a, Stub $stub, bool $isNested)
50+
public static function castRedis(\Redis|Relay $c, array $a, Stub $stub, bool $isNested)
5051
{
5152
$prefix = Caster::PREFIX_VIRTUAL;
5253

@@ -102,9 +103,9 @@ public static function castRedisCluster(\RedisCluster $c, array $a, Stub $stub,
102103
return $a;
103104
}
104105

105-
private static function getRedisOptions(\Redis|\RedisArray|\RedisCluster $redis, array $options = []): EnumStub
106+
private static function getRedisOptions(\Redis|Relay|\RedisArray|\RedisCluster $redis, array $options = []): EnumStub
106107
{
107-
$serializer = $redis->getOption(\Redis::OPT_SERIALIZER);
108+
$serializer = $redis->getOption(\defined('Redis::OPT_SERIALIZER') ? \Redis::OPT_SERIALIZER : 1);
108109
if (\is_array($serializer)) {
109110
foreach ($serializer as &$v) {
110111
if (isset(self::SERIALIZERS[$v])) {
@@ -136,11 +137,11 @@ private static function getRedisOptions(\Redis|\RedisArray|\RedisCluster $redis,
136137
}
137138

138139
$options += [
139-
'TCP_KEEPALIVE' => \defined('Redis::OPT_TCP_KEEPALIVE') ? $redis->getOption(\Redis::OPT_TCP_KEEPALIVE) : 0,
140-
'READ_TIMEOUT' => $redis->getOption(\Redis::OPT_READ_TIMEOUT),
140+
'TCP_KEEPALIVE' => \defined('Redis::OPT_TCP_KEEPALIVE') ? $redis->getOption(\Redis::OPT_TCP_KEEPALIVE) : Relay::OPT_TCP_KEEPALIVE,
141+
'READ_TIMEOUT' => $redis->getOption(\defined('Redis::OPT_READ_TIMEOUT') ? \Redis::OPT_READ_TIMEOUT : Relay::OPT_READ_TIMEOUT),
141142
'COMPRESSION' => $compression,
142143
'SERIALIZER' => $serializer,
143-
'PREFIX' => $redis->getOption(\Redis::OPT_PREFIX),
144+
'PREFIX' => $redis->getOption(\defined('Redis::OPT_PREFIX') ? \Redis::OPT_PREFIX : Relay::OPT_PREFIX),
144145
'SCAN' => $retry,
145146
];
146147

‎src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ abstract class AbstractCloner implements ClonerInterface
130130
'WeakReference' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castWeakReference'],
131131

132132
'Redis' => ['Symfony\Component\VarDumper\Caster\RedisCaster', 'castRedis'],
133+
'Relay\Relay' => ['Symfony\Component\VarDumper\Caster\RedisCaster', 'castRedis'],
133134
'RedisArray' => ['Symfony\Component\VarDumper\Caster\RedisCaster', 'castRedisArray'],
134135
'RedisCluster' => ['Symfony\Component\VarDumper\Caster\RedisCaster', 'castRedisCluster'],
135136

‎src/Symfony/Component/VarDumper/Tests/Caster/RedisCasterTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Tests/Caster/RedisCasterTest.php
+16-6Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616

1717
/**
1818
* @author Nicolas Grekas <p@tchwork.com>
19-
* @requires extension redis
2019
* @group integration
2120
*/
2221
class RedisCasterTest extends TestCase
2322
{
2423
use VarDumperTestTrait;
2524

25+
/**
26+
* @requires extension redis
27+
*/
2628
public function testNotConnected()
2729
{
2830
$redis = new \Redis();
@@ -36,18 +38,26 @@ public function testNotConnected()
3638
$this->assertDumpMatchesFormat($xCast, $redis);
3739
}
3840

39-
public function testConnected()
41+
/**
42+
* @testWith ["Redis"]
43+
* ["Relay\\Relay"]
44+
*/
45+
public function testConnected(string $class)
4046
{
47+
if (!class_exists($class)) {
48+
self::markTestSkipped(sprintf('"%s" class required', $class));
49+
}
50+
4151
$redisHost = explode(':', getenv('REDIS_HOST')) + [1 => 6379];
42-
$redis = new \Redis();
52+
$redis = new $class;
4353
try {
4454
$redis->connect(...$redisHost);
4555
} catch (\Exception $e) {
4656
self::markTestSkipped($e->getMessage());
4757
}
4858

4959
$xCast = <<<EODUMP
50-
Redis {%A
60+
%a {%A
5161
isConnected: true
5262
host: "{$redisHost[0]}"
5363
port: {$redisHost[1]}
@@ -56,9 +66,9 @@ public function testConnected()
5666
dbNum: 0
5767
timeout: 0.0
5868
lastError: null
59-
persistentId: null
69+
persistentId: %a
6070
options: {
61-
TCP_KEEPALIVE: 0
71+
TCP_KEEPALIVE: %a
6272
READ_TIMEOUT: 0.0
6373
COMPRESSION: NONE
6474
SERIALIZER: NONE

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.