Skip to content

[Cache] Fix generating proxies when ext-redis v6 is installed #51136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions src/Symfony/Component/Cache/Tests/Traits/RedisProxiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
use Symfony\Component\VarExporter\LazyProxyTrait;
use Symfony\Component\VarExporter\ProxyHelper;

/**
* @requires extension redis
*/
class RedisProxiesTest extends TestCase
{
/**
* @requires extension redis < 6
*
* @testWith ["Redis"]
* ["RedisCluster"]
*/
Expand Down Expand Up @@ -50,24 +49,31 @@ public function testRedis5Proxy($class)
}

/**
* @requires extension redis
*
* @testWith ["Redis", "redis"]
* ["RedisCluster", "redis_cluster"]
*/
public function testRedis6Proxy($class, $stub)
{
$this->markTestIncomplete('To be re-enabled when phpredis v6 becomes stable');
if (version_compare(phpversion('redis'), '6.0.0', '<')) {
$this->markTestIncomplete('To be re-enabled when phpredis v6 becomes stable');

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

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

foreach ((new \ReflectionClass($class.'StubInterface'))->getMethods() as $method) {
foreach ($r->getMethods() as $method) {
if ('reset' === $method->name || method_exists(LazyProxyTrait::class, $method->name)) {
continue;
}
Expand Down