Skip to content

[Cache] fix compatibility with different Relay versions #61220

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 24, 2025
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
6 changes: 3 additions & 3 deletions src/Symfony/Component/Cache/Tests/Traits/RedisProxiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ public function testRelayProxy()
$expectedMethods = [];

foreach ((new \ReflectionClass(RelayProxy::class))->getMethods() as $method) {
if ('reset' === $method->name || method_exists(LazyProxyTrait::class, $method->name) || $method->isStatic()) {
if ('reset' === $method->name || method_exists(LazyProxyTrait::class, $method->name) || $method->isInternal()) {
Copy link
Member

Choose a reason for hiding this comment

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

why this change ?

Copy link
Member

Choose a reason for hiding this comment

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

continue;
}

$return = $method->getReturnType() instanceof \ReflectionNamedType && 'void' === (string) $method->getReturnType() ? '' : 'return ';
$expectedMethods[$method->name] = "\n ".ProxyHelper::exportSignature($method, false, $args)."\n".<<<EOPHP
$expectedMethods[$method->name] = "\n ".ProxyHelper::exportSignature($method, true, $args)."\n".<<<EOPHP
{
{$return}(\$this->lazyObjectState->realInstance ??= (\$this->lazyObjectState->initializer)())->{$method->name}({$args});
}
Expand All @@ -101,7 +101,7 @@ public function testRelayProxy()
}

foreach ((new \ReflectionClass(Relay::class))->getMethods() as $method) {
if ('reset' === $method->name || method_exists(LazyProxyTrait::class, $method->name) || $method->isStatic()) {
if ('__destruct' === $method->name || 'reset' === $method->name || $method->isStatic()) {
continue;
}
$return = $method->getReturnType() instanceof \ReflectionNamedType && 'void' === (string) $method->getReturnType() ? '' : 'return ';
Expand Down
132 changes: 132 additions & 0 deletions src/Symfony/Component/Cache/Traits/Relay/FtTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<?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\Relay;

if (version_compare(phpversion('relay'), '0.9.0', '>=')) {
/**
* @internal
*/
trait FtTrait
{
public function ftAggregate($index, $query, $options = null): \Relay\Relay|array|false
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftAggregate(...\func_get_args());
}

public function ftAliasAdd($index, $alias): \Relay\Relay|bool
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftAliasAdd(...\func_get_args());
}

public function ftAliasDel($alias): \Relay\Relay|bool
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftAliasDel(...\func_get_args());
}

public function ftAliasUpdate($index, $alias): \Relay\Relay|bool
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftAliasUpdate(...\func_get_args());
}

public function ftAlter($index, $schema, $skipinitialscan = false): \Relay\Relay|bool
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftAlter(...\func_get_args());
}

public function ftConfig($operation, $option, $value = null): \Relay\Relay|array|bool
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftConfig(...\func_get_args());
}

public function ftCreate($index, $schema, $options = null): \Relay\Relay|bool
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftCreate(...\func_get_args());
}

public function ftCursor($operation, $index, $cursor, $options = null): \Relay\Relay|array|bool
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftCursor(...\func_get_args());
}

public function ftDictAdd($dict, $term, ...$other_terms): \Relay\Relay|false|int
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftDictAdd(...\func_get_args());
}

public function ftDictDel($dict, $term, ...$other_terms): \Relay\Relay|false|int
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftDictDel(...\func_get_args());
}

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

public function ftDropIndex($index, $dd = false): \Relay\Relay|bool
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftDropIndex(...\func_get_args());
}

public function ftExplain($index, $query, $dialect = 0): \Relay\Relay|false|string
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftExplain(...\func_get_args());
}

public function ftExplainCli($index, $query, $dialect = 0): \Relay\Relay|array|false
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftExplainCli(...\func_get_args());
}

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

public function ftProfile($index, $command, $query, $limited = false): \Relay\Relay|array|false
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftProfile(...\func_get_args());
}

public function ftSearch($index, $query, $options = null): \Relay\Relay|array|false
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftSearch(...\func_get_args());
}

public function ftSpellCheck($index, $query, $options = null): \Relay\Relay|array|false
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftSpellCheck(...\func_get_args());
}

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

public function ftSynUpdate($index, $synonym, $term_or_terms, $skipinitialscan = false): \Relay\Relay|bool
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftSynUpdate(...\func_get_args());
}

public function ftTagVals($index, $tag): \Relay\Relay|array|false
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftTagVals(...\func_get_args());
}
}
} else {
/**
* @internal
*/
trait FtTrait

Check failure on line 129 in src/Symfony/Component/Cache/Traits/Relay/FtTrait.php

View workflow job for this annotation

GitHub Actions / Psalm

DuplicateClass

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

Check failure on line 129 in src/Symfony/Component/Cache/Traits/Relay/FtTrait.php

View workflow job for this annotation

GitHub Actions / Psalm

DuplicateClass

src/Symfony/Component/Cache/Traits/Relay/FtTrait.php:129:11: DuplicateClass: Class Symfony\Component\Cache\Traits\Relay\FtTrait has already been defined in /home/runner/work/symfony/symfony/src/Symfony/Component/Cache/Traits/Relay/FtTrait.php (see https://psalm.dev/071)
{
}
}
32 changes: 32 additions & 0 deletions src/Symfony/Component/Cache/Traits/Relay/GetWithMetaTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?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\Relay;

if (version_compare(phpversion('relay'), '0.10.1', '>=')) {
/**
* @internal
*/
trait GetWithMetaTrait
{
public function getWithMeta($key): \Relay\Relay|array|false
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getWithMeta(...\func_get_args());
}
}
} else {
/**
* @internal
*/
trait GetWithMetaTrait

Check failure on line 29 in src/Symfony/Component/Cache/Traits/Relay/GetWithMetaTrait.php

View workflow job for this annotation

GitHub Actions / Psalm

DuplicateClass

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

Check failure on line 29 in src/Symfony/Component/Cache/Traits/Relay/GetWithMetaTrait.php

View workflow job for this annotation

GitHub Actions / Psalm

DuplicateClass

src/Symfony/Component/Cache/Traits/Relay/GetWithMetaTrait.php:29:11: DuplicateClass: Class Symfony\Component\Cache\Traits\Relay\GetWithMetaTrait has already been defined in /home/runner/work/symfony/symfony/src/Symfony/Component/Cache/Traits/Relay/GetWithMetaTrait.php (see https://psalm.dev/071)
{
}
}
32 changes: 32 additions & 0 deletions src/Symfony/Component/Cache/Traits/Relay/IsTrackedTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?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\Relay;

if (version_compare(phpversion('relay'), '0.11.1', '>=')) {
/**
* @internal
*/
trait IsTrackedTrait
{
public function isTracked($key): bool
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->isTracked(...\func_get_args());
}
}
} else {
/**
* @internal
*/
trait IsTrackedTrait

Check failure on line 29 in src/Symfony/Component/Cache/Traits/Relay/IsTrackedTrait.php

View workflow job for this annotation

GitHub Actions / Psalm

DuplicateClass

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

Check failure on line 29 in src/Symfony/Component/Cache/Traits/Relay/IsTrackedTrait.php

View workflow job for this annotation

GitHub Actions / Psalm

DuplicateClass

src/Symfony/Component/Cache/Traits/Relay/IsTrackedTrait.php:29:11: DuplicateClass: Class Symfony\Component\Cache\Traits\Relay\IsTrackedTrait has already been defined in /home/runner/work/symfony/symfony/src/Symfony/Component/Cache/Traits/Relay/IsTrackedTrait.php (see https://psalm.dev/071)
{
}
}
132 changes: 132 additions & 0 deletions src/Symfony/Component/Cache/Traits/Relay/Relay11Trait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<?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\Relay;

if (version_compare(phpversion('relay'), '0.11.0', '>=')) {
/**
* @internal
*/
trait Relay11Trait
{
public function cmsIncrBy($key, $field, $value, ...$fields_and_falues): \Relay\Relay|array|false
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->cmsIncrBy(...\func_get_args());
}

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

public function cmsInitByDim($key, $width, $depth): \Relay\Relay|bool
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->cmsInitByDim(...\func_get_args());
}

public function cmsInitByProb($key, $error, $probability): \Relay\Relay|bool
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->cmsInitByProb(...\func_get_args());
}

public function cmsMerge($dstkey, $keys, $weights = []): \Relay\Relay|bool
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->cmsMerge(...\func_get_args());
}

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

public function commandlog($subcmd, ...$args): \Relay\Relay|array|bool|int
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->commandlog(...\func_get_args());
}

public function hexpire($hash, $ttl, $fields, $mode = null): \Relay\Relay|array|false
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hexpire(...\func_get_args());
}

public function hexpireat($hash, $ttl, $fields, $mode = null): \Relay\Relay|array|false
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hexpireat(...\func_get_args());
}

public function hexpiretime($hash, $fields): \Relay\Relay|array|false
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hexpiretime(...\func_get_args());
}

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

public function hgetex($hash, $fields, $expiry = null): \Relay\Relay|array|false
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hgetex(...\func_get_args());
}

public function hpersist($hash, $fields): \Relay\Relay|array|false
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hpersist(...\func_get_args());
}

public function hpexpire($hash, $ttl, $fields, $mode = null): \Relay\Relay|array|false
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hpexpire(...\func_get_args());
}

public function hpexpireat($hash, $ttl, $fields, $mode = null): \Relay\Relay|array|false
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hpexpireat(...\func_get_args());
}

public function hpexpiretime($hash, $fields): \Relay\Relay|array|false
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hpexpiretime(...\func_get_args());
}

public function hpttl($hash, $fields): \Relay\Relay|array|false
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hpttl(...\func_get_args());
}

public function hsetex($key, $fields, $expiry = null): \Relay\Relay|false|int
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hsetex(...\func_get_args());
}

public function httl($hash, $fields): \Relay\Relay|array|false
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->httl(...\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 Relay11Trait

Check failure on line 129 in src/Symfony/Component/Cache/Traits/Relay/Relay11Trait.php

View workflow job for this annotation

GitHub Actions / Psalm

DuplicateClass

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

Check failure on line 129 in src/Symfony/Component/Cache/Traits/Relay/Relay11Trait.php

View workflow job for this annotation

GitHub Actions / Psalm

DuplicateClass

src/Symfony/Component/Cache/Traits/Relay/Relay11Trait.php:129:11: DuplicateClass: Class Symfony\Component\Cache\Traits\Relay\Relay11Trait has already been defined in /home/runner/work/symfony/symfony/src/Symfony/Component/Cache/Traits/Relay/Relay11Trait.php (see https://psalm.dev/071)
{
}
}
32 changes: 32 additions & 0 deletions src/Symfony/Component/Cache/Traits/Relay/SwapdbTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?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\Relay;

if (version_compare(phpversion('relay'), '0.9.0', '>=')) {
/**
* @internal
*/
trait SwapdbTrait
{
public function swapdb($index1, $index2): \Relay\Relay|bool
{
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->swapdb(...\func_get_args());
}
}
} else {
/**
* @internal
*/
trait SwapdbTrait

Check failure on line 29 in src/Symfony/Component/Cache/Traits/Relay/SwapdbTrait.php

View workflow job for this annotation

GitHub Actions / Psalm

DuplicateClass

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

Check failure on line 29 in src/Symfony/Component/Cache/Traits/Relay/SwapdbTrait.php

View workflow job for this annotation

GitHub Actions / Psalm

DuplicateClass

src/Symfony/Component/Cache/Traits/Relay/SwapdbTrait.php:29:11: DuplicateClass: Class Symfony\Component\Cache\Traits\Relay\SwapdbTrait has already been defined in /home/runner/work/symfony/symfony/src/Symfony/Component/Cache/Traits/Relay/SwapdbTrait.php (see https://psalm.dev/071)
{
}
}
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy