8000 minor #51136 [Cache] Fix generating proxies when ext-redis v6 is inst… · fancyweb/symfony@5dfc9f3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5dfc9f3

Browse files
minor symfony#51136 [Cache] Fix generating proxies when ext-redis v6 is installed (nicolas-grekas)
This PR was merged into the 6.2 branch. Discussion ---------- [Cache] Fix generating proxies when ext-redis v6 is installed | Q | A | ------------- | --- | Branch? | 6.2 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Commits ------- 4da5a79 [Cache] Fix generating proxies when ext-redis v6 is installed
2 parents 657abf3 + 4da5a79 commit 5dfc9f3

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/Symfony/Component/Cache/Tests/Traits/RedisProxiesTest.php

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
use Symfony\Component\VarExporter\LazyProxyTrait;
1616
use Symfony\Component\VarExporter\ProxyHelper;
1717

18-
/**
19-
* @requires extension redis
20-
*/
2118
class RedisProxiesTest extends TestCase
2219
{
2320
/**
21+
* @requires extension redis < 6
22+
*
2423
* @testWith ["Redis"]
2524
* ["RedisCluster"]
2625
*/
@@ -50,24 +49,31 @@ public function testRedis5Proxy($class)
5049
}
5150

5251
/**
52+
* @requires extension redis
53+
*
5354
* @testWith ["Redis", "redis"]
5455
* ["RedisCluster", "redis_cluster"]
5556
*/
5657
public function testRedis6Proxy($class, $stub)
5758
{
58-
$this->markTestIncomplete('To be re-enabled when phpredis v6 becomes stable');
59+
if (version_compare(phpversion('redis'), '6.0.0', '<')) {
60+
$this->markTestIncomplete('To be re-enabled when phpredis v6 becomes stable');
5961

60-
$stub = file_get_contents("https://raw.githubusercontent.com/phpredis/phpredis/develop/{$stub}.stub.php");
61-
$stub = preg_replace('/^class /m', 'return; \0', $stub);
62-
$stub = preg_replace('/^return; class ([a-zA-Z]++)/m', 'interface \1StubInterface', $stub, 1);
63-
$stub = preg_replace('/^ public const .*/m', '', $stub);
64-
eval(substr($stub, 5));
62+
$stub = file_get_contents("https://raw.githubusercontent.com/phpredis/phpredis/develop/{$stub}.stub.php");
63+
$stub = preg_replace('/^class /m', 'return; \0', $stub);
64+
$stub = preg_replace('/^return; class ([a-zA-Z]++)/m', 'interface \1StubInterface', $stub, 1);
65+
$stub = preg_replace('/^ public const .*/m', '', $stub);
66+
eval(substr($stub, 5));
67+
$r = new \ReflectionClass($class.'StubInterface');
68+
} else {
69+
$r = new \ReflectionClass($class);
70+
}
6571

6672
$proxy = file_get_contents(\dirname(__DIR__, 2)."/Traits/{$class}6Proxy.php");
6773
$proxy = substr($proxy, 0, 4 + strpos($proxy, '[];'));
6874
$methods = [];
6975

70-
foreach ((new \ReflectionClass($class.'StubInterface'))->getMethods() as $method) {
76+
foreach ($r->getMethods() as $method) {
7177
if ('reset' === $method->name || method_exists(LazyProxyTrait::class, $method->name)) {
7278
continue;
7379
}

0 commit comments

Comments
 (0)
0