Skip to content
Merged
Show file tree
Hide file tree
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
14 changes: 7 additions & 7 deletions src/Symfony/Component/Cache/Tests/Traits/RedisProxiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ public function testRedisProxy($class)
$methods = [];

foreach ((new \ReflectionClass(\sprintf('Symfony\Component\Cache\Traits\\%s%dProxy', $class, $version)))->getMethods() as $method) {
if ('reset' === $method->name || method_exists(LazyProxyTrait::class, $method->name)) {
if ('reset' === $method->name || method_exists(LazyProxyTrait::class, $method->name) || $method->isInternal()) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is required to make the tests fail when our proxies miss a method. The other changes in this test reduce the diff with the version in the 7.4 branch.

continue;
}
$return = $method->getReturnType() instanceof \ReflectionNamedType && 'void' === (string) $method->getReturnType() ? '' : 'return ';
$methods[$method->name] = "\n ".ProxyHelper::exportSignature($method, false, $args)."\n".<<<EOPHP
$return = '__construct' === $method->name || $method->getReturnType() instanceof \ReflectionNamedType && 'void' === (string) $method->getReturnType() ? '' : 'return ';
$methods[$method->name] = "\n ".ProxyHelper::exportSignature($method, true, $args)."\n".<<<EOPHP
{
{$return}(\$this->lazyObjectState->realInstance ??= (\$this->lazyObjectState->initializer)())->{$method->name}({$args});
}
Expand All @@ -52,10 +52,10 @@ public function testRedisProxy($class)
$methods = [];

foreach ((new \ReflectionClass($class))->getMethods() as $method) {
if ('reset' === $method->name || method_exists(LazyProxyTrait::class, $method->name)) {
if ('__destruct' === $method->name || 'reset' === $method->name) {
continue;
}
$return = $method->getReturnType() instanceof \ReflectionNamedType && 'void' === (string) $method->getReturnType() ? '' : 'return ';
$return = '__construct' === $method->name || $method->getReturnType() instanceof \ReflectionNamedType && 'void' === (string) $method->getReturnType() ? '' : 'return ';
$methods[$method->name] = "\n ".ProxyHelper::exportSignature($method, false, $args)."\n".<<<EOPHP
{
{$return}(\$this->lazyObjectState->realInstance ??= (\$this->lazyObjectState->initializer)())->{$method->name}({$args});
Expand Down Expand Up @@ -91,7 +91,7 @@ public function testRelayProxy()
continue;
}

$return = $method->getReturnType() instanceof \ReflectionNamedType && 'void' === (string) $method->getReturnType() ? '' : 'return ';
$return = '__construct' === $method->name || $method->getReturnType() instanceof \ReflectionNamedType && 'void' === (string) $method->getReturnType() ? '' : 'return ';
$expectedMethods[$method->name] = "\n ".ProxyHelper::exportSignature($method, true, $args)."\n".<<<EOPHP
{
{$return}(\$this->lazyObjectState->realInstance ??= (\$this->lazyObjectState->initializer)())->{$method->name}({$args});
Expand All @@ -104,7 +104,7 @@ public function testRelayProxy()
if ('__destruct' === $method->name || 'reset' === $method->name || $method->isStatic()) {
continue;
}
$return = $method->getReturnType() instanceof \ReflectionNamedType && 'void' === (string) $method->getReturnType() ? '' : 'return ';
$return = '__construct' === $method->name || $method->getReturnType() instanceof \ReflectionNamedType && 'void' === (string) $method->getReturnType() ? '' : 'return ';
$methods[$method->name] = "\n ".ProxyHelper::exportSignature($method, false, $args)."\n".<<<EOPHP
{
{$return}(\$this->lazyObjectState->realInstance ??= (\$this->lazyObjectState->initializer)())->{$method->name}({$args});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/**
* @internal
*/
trait Redis6ProxyTrait
trait Redis61ProxyTrait
{
public function dump($key): \Redis|string|false
{
Expand All @@ -37,7 +37,7 @@
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->mget(...\func_get_args());
}

public function sRandMember($key, $count = 0): mixed

Check failure on line 40 in src/Symfony/Component/Cache/Traits/Redis61ProxyTrait.php

View workflow job for this annotation

GitHub Actions / Psalm

LessSpecificImplementedReturnType

src/Symfony/Component/Cache/Traits/Redis61ProxyTrait.php:40:56: LessSpecificImplementedReturnType: The inherited return type 'array<array-key, mixed>|false|string' for Redis::sRandMember is more specific than the implemented return type for Symfony\Component\Cache\Traits\Redis61ProxyTrait::srandmember 'mixed' (see https://psalm.dev/166)

Check failure on line 40 in src/Symfony/Component/Cache/Traits/Redis61ProxyTrait.php

View workflow job for this annotation

GitHub Actions / Psalm

LessSpecificImplementedReturnType

src/Symfony/Component/Cache/Traits/Redis61ProxyTrait.php:40:56: LessSpecificImplementedReturnType: The inherited return type 'array<array-key, mixed>|false|string' for Redis::sRandMember is more specific than the implemented return type for Symfony\Component\Cache\Traits\Redis61ProxyTrait::srandmember 'mixed' (see https://psalm.dev/166)
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sRandMember(...\func_get_args());
}
Expand All @@ -51,7 +51,7 @@
/**
* @internal
*/
trait Redis6ProxyTrait
trait Redis61ProxyTrait

Check failure on line 54 in src/Symfony/Component/Cache/Traits/Redis61ProxyTrait.php

View workflow job for this annotation

GitHub Actions / Psalm

DuplicateClass

src/Symfony/Component/Cache/Traits/Redis61ProxyTrait.php:54:11: DuplicateClass: Class Symfony\Component\Cache\Traits\Redis61ProxyTrait has already been defined in /home/runner/work/symfony/symfony/src/Symfony/Component/Cache/Traits/Redis61ProxyTrait.php (see https://psalm.dev/071)

Check failure on line 54 in src/Symfony/Component/Cache/Traits/Redis61ProxyTrait.php

View workflow job for this annotation

GitHub Actions / Psalm

DuplicateClass

src/Symfony/Component/Cache/Traits/Redis61ProxyTrait.php:54:11: DuplicateClass: Class Symfony\Component\Cache\Traits\Redis61ProxyTrait has already been defined in /home/runner/work/symfony/symfony/src/Symfony/Component/Cache/Traits/Redis61ProxyTrait.php (see https://psalm.dev/071)
{
public function dump($key): \Redis|string
{
Expand Down
52 changes: 52 additions & 0 deletions src/Symfony/Component/Cache/Traits/Redis62ProxyTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Cache\Traits;

if (version_compare(phpversion('redis'), '6.2.0', '>=')) {
/**
* @internal
*/
trait Redis62ProxyTrait
{
public function expiremember($key, $field, $ttl, $unit = null): \Redis|false|int
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->expiremember(...\func_get_args());
}

public function expirememberat($key, $field, $timestamp): \Redis|false|int
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->expirememberat(...\func_get_args());
}

public function getWithMeta($key): \Redis|array|false
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getWithMeta(...\func_get_args());
}

public function serverName(): false|string
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->serverName(...\func_get_args());
}

public function serverVersion(): false|string
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->serverVersion(...\func_get_args());
}
}
} else {
/**
* @internal
*/
trait Redis62ProxyTrait

Check failure on line 49 in src/Symfony/Component/Cache/Traits/Redis62ProxyTrait.php

View workflow job for this annotation

GitHub Actions / Psalm

DuplicateClass

src/Symfony/Component/Cache/Traits/Redis62ProxyTrait.php:49:11: DuplicateClass: Class Symfony\Component\Cache\Traits\Redis62ProxyTrait has already been defined in /home/runner/work/symfony/symfony/src/Symfony/Component/Cache/Traits/Redis62ProxyTrait.php (see https://psalm.dev/071)

Check failure on line 49 in src/Symfony/Component/Cache/Traits/Redis62ProxyTrait.php

View workflow job for this annotation

GitHub Actions / Psalm

DuplicateClass

src/Symfony/Component/Cache/Traits/Redis62ProxyTrait.php:49:11: DuplicateClass: Class Symfony\Component\Cache\Traits\Redis62ProxyTrait has already been defined in /home/runner/work/symfony/symfony/src/Symfony/Component/Cache/Traits/Redis62ProxyTrait.php (see https://psalm.dev/071)
{
}
}
3 changes: 2 additions & 1 deletion src/Symfony/Component/Cache/Traits/Redis6Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class);
*/
class Redis6Proxy extends \Redis implements ResetInterface, LazyObjectInterface
{
use Redis6ProxyTrait;
use Redis61ProxyTrait;
use Redis62ProxyTrait;
use LazyProxyTrait {
resetLazyObject as reset;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/**
* @internal
*/
trait RedisCluster6ProxyTrait
trait RedisCluster61ProxyTrait
{
public function getex($key, $options = []): \RedisCluster|string|false
{
Expand All @@ -36,7 +36,7 @@
/**
* @internal
*/
trait RedisCluster6ProxyTrait
trait RedisCluster61ProxyTrait

Check failure on line 39 in src/Symfony/Component/Cache/Traits/RedisCluster61ProxyTrait.php

View workflow job for this annotation

GitHub Actions / Psalm

DuplicateClass

src/Symfony/Component/Cache/Traits/RedisCluster61ProxyTrait.php:39:11: DuplicateClass: Class Symfony\Component\Cache\Traits\RedisCluster61ProxyTrait has already been defined in /home/runner/work/symfony/symfony/src/Symfony/Component/Cache/Traits/RedisCluster61ProxyTrait.php (see https://psalm.dev/071)

Check failure on line 39 in src/Symfony/Component/Cache/Traits/RedisCluster61ProxyTrait.php

View workflow job for this annotation

GitHub Actions / Psalm

DuplicateClass

src/Symfony/Component/Cache/Traits/RedisCluster61ProxyTrait.php:39:11: DuplicateClass: Class Symfony\Component\Cache\Traits\RedisCluster61ProxyTrait has already been defined in /home/runner/work/symfony/symfony/src/Symfony/Component/Cache/Traits/RedisCluster61ProxyTrait.php (see https://psalm.dev/071)
{
public function publish($channel, $message): \RedisCluster|bool
{
Expand Down
47 changes: 47 additions & 0 deletions src/Symfony/Component/Cache/Traits/RedisCluster62ProxyTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Cache\Traits;

if (version_compare(phpversion('redis'), '6.2.0', '>=')) {
/**
* @internal
*/
trait RedisCluster62ProxyTrait
{
public function expiremember($key, $field, $ttl, $unit = null): \Redis|false|int
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->expiremember(...\func_get_args());
}

public function expirememberat($key, $field, $timestamp): \Redis|false|int
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->expirememberat(...\func_get_args());
}

public function getdel($key): mixed
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getdel(...\func_get_args());
}

public function getWithMeta($key): \RedisCluster|array|false
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getWithMeta(...\func_get_args());
}
}
} else {
/**
* @internal
*/
trait RedisCluster62ProxyTrait

Check failure on line 44 in src/Symfony/Component/Cache/Traits/RedisCluster62ProxyTrait.php

View workflow job for this annotation

GitHub Actions / Psalm

DuplicateClass

src/Symfony/Component/Cache/Traits/RedisCluster62ProxyTrait.php:44:11: DuplicateClass: Class Symfony\Component\Cache\Traits\RedisCluster62ProxyTrait has already been defined in /home/runner/work/symfony/symfony/src/Symfony/Component/Cache/Traits/RedisCluster62ProxyTrait.php (see https://psalm.dev/071)

Check failure on line 44 in src/Symfony/Component/Cache/Traits/RedisCluster62ProxyTrait.php

View workflow job for this annotation

GitHub Actions / Psalm

DuplicateClass

src/Symfony/Component/Cache/Traits/RedisCluster62ProxyTrait.php:44:11: DuplicateClass: Class Symfony\Component\Cache\Traits\RedisCluster62ProxyTrait has already been defined in /home/runner/work/symfony/symfony/src/Symfony/Component/Cache/Traits/RedisCluster62ProxyTrait.php (see https://psalm.dev/071)
{
}
}
3 changes: 2 additions & 1 deletion src/Symfony/Component/Cache/Traits/RedisCluster6Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class);
*/
class RedisCluster6Proxy extends \RedisCluster implements ResetInterface, LazyObjectInterface
{
use RedisCluster6ProxyTrait;
use RedisCluster61ProxyTrait;
use RedisCluster62ProxyTrait;
use LazyProxyTrait {
resetLazyObject as reset;
}
Expand Down
Loading