Skip to content

Commit 884bfff

Browse files
committed
fix compatibility with different Relay versions
1 parent da8bc22 commit 884bfff

File tree

8 files changed

+381
-6
lines changed

8 files changed

+381
-6
lines changed

.github/workflows/unit-tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,14 @@ jobs:
112112
SYMFONY_VERSION=$(echo "$SYMFONY_VERSIONS" | grep -FB1 /$SYMFONY_VERSION | head -n 1 | sed s/.//)
113113
git fetch --depth=2 origin $SYMFONY_VERSION
114114
git checkout -m FETCH_HEAD
115-
echo COMPONENTS=$(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist -printf '%h ') >> $GITHUB_ENV
115+
echo COMPONENTS=src/Symfony/Component/Cache >> $GITHUB_ENV
116116
fi
117117
118118
# Skip the phpunit-bridge on bugfix-branches when not in *-deps mode
119119
if [[ ! "${{ matrix.mode }}" = *-deps && $SYMFONY_VERSION != $SYMFONY_FEATURE_BRANCH ]]; then
120-
echo COMPONENTS=$(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist -not -wholename '*/Bridge/PhpUnit/*' | xargs -I{} dirname {}) >> $GITHUB_ENV
120+
echo COMPONENTS=src/Symfony/Component/Cache >> $GITHUB_ENV
121121
else
122-
echo COMPONENTS=$(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist | xargs -I{} dirname {}) >> $GITHUB_ENV
122+
echo COMPONENTS=src/Symfony/Component/Cache >> $GITHUB_ENV
123123
fi
124124
125125
# Legacy tests are skipped when deps=high and when the current branch version has not the same major version number as the next one

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@ public function testRelayProxy()
8787
$expectedMethods = [];
8888

8989
foreach ((new \ReflectionClass(RelayProxy::class))->getMethods() as $method) {
90-
if ('reset' === $method->name || method_exists(LazyProxyTrait::class, $method->name) || $method->isStatic()) {
90+
if ('reset' === $method->name || method_exists(LazyProxyTrait::class, $method->name) || $method->isInternal()) {
9191
continue;
9292
}
9393

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

103103
foreach ((new \ReflectionClass(Relay::class))->getMethods() as $method) {
104-
if ('reset' === $method->name || method_exists(LazyProxyTrait::class, $method->name) || $method->isStatic()) {
104+
if ('__destruct' === $method->name || 'reset' === $method->name || $method->isStatic()) {
105105
continue;
106106
}
107107
$return = $method->getReturnType() instanceof \ReflectionNamedType && 'void' === (string) $method->getReturnType() ? '' : 'return ';
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Cache\Traits\Relay;
13+
14+
var_dump(phpversion('relay'));
15+
16+
if (version_compare(phpversion('relay'), '0.9.0', '>=')) {
17+
/**
18+
* @internal
19+
*/
20+
trait FtTrait
21+
{
22+
public function ftAggregate($index, $query, $options = null): \Relay\Relay|array|false
23+
{
24+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftAggregate(...\func_get_args());
25+
}
26+
27+
public function ftAliasAdd($index, $alias): \Relay\Relay|bool
28+
{
29+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftAliasAdd(...\func_get_args());
30+
}
31+
32+
public function ftAliasDel($alias): \Relay\Relay|bool
33+
{
34+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftAliasDel(...\func_get_args());
35+
}
36+
37+
public function ftAliasUpdate($index, $alias): \Relay\Relay|bool
38+
{
39+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftAliasUpdate(...\func_get_args());
40+
}
41+
42+
public function ftAlter($index, $schema, $skipinitialscan = false): \Relay\Relay|bool
43+
{
44+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftAlter(...\func_get_args());
45+
}
46+
47+
public function ftConfig($operation, $option, $value = null): \Relay\Relay|array|bool
48+
{
49+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftConfig(...\func_get_args());
50+
}
51+
52+
public function ftCreate($index, $schema, $options = null): \Relay\Relay|bool
53+
{
54+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftCreate(...\func_get_args());
55+
}
56+
57+
public function ftCursor($operation, $index, $cursor, $options = null): \Relay\Relay|array|bool
58+
{
59+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftCursor(...\func_get_args());
60+
}
61+
62+
public function ftDictAdd($dict, $term, ...$other_terms): \Relay\Relay|false|int
63+
{
64+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftDictAdd(...\func_get_args());
65+
}
66+
67+
public function ftDictDel($dict, $term, ...$other_terms): \Relay\Relay|false|int
68+
{
69+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftDictDel(...\func_get_args());
70+
}
71+
72+
public function ftDictDump($dict): \Relay\Relay|array|false
73+
{
74+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftDictDump(...\func_get_args());
75+
}
76+
77+
public function ftDropIndex($index, $dd = false): \Relay\Relay|bool
78+
{
79+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftDropIndex(...\func_get_args());
80+
}
81+
82+
public function ftExplain($index, $query, $dialect = 0): \Relay\Relay|false|string
83+
{
84+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftExplain(...\func_get_args());
85+
}
86+
87+
public function ftExplainCli($index, $query, $dialect = 0): \Relay\Relay|array|false
88+
{
89+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftExplainCli(...\func_get_args());
90+
}
91+
92+
public function ftInfo($index): \Relay\Relay|array|false
93+
{
94+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftInfo(...\func_get_args());
95+
}
96+
97+
public function ftProfile($index, $command, $query, $limited = false): \Relay\Relay|array|false
98+
{
99+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftProfile(...\func_get_args());
100+
}
101+
102+
public function ftSearch($index, $query, $options = null): \Relay\Relay|array|false
103+
{
104+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftSearch(...\func_get_args());
105+
}
106+
107+
public function ftSpellCheck($index, $query, $options = null): \Relay\Relay|array|false
108+
{
109+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftSpellCheck(...\func_get_args());
110+
}
111+
112+
public function ftSynDump($index): \Relay\Relay|array|false
113+
{
114+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftSynDump(...\func_get_args());
115+
}
116+
117+
public function ftSynUpdate($index, $synonym, $term_or_terms, $skipinitialscan = false): \Relay\Relay|bool
118+
{
119+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftSynUpdate(...\func_get_args());
120+
}
121+
122+
public function ftTagVals($index, $tag): \Relay\Relay|array|false
123+
{
124+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftTagVals(...\func_get_args());
125+
}
126+
}
127+
} else {
128+
/**
129+
* @internal
130+
*/
131+
trait FtTrait
132+
{
133+
}
134+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Cache\Traits\Relay;
13+
14+
if (version_compare(phpversion('relay'), '0.10.1', '>=')) {
15+
/**
16+
* @internal
17+
*/
18+
trait GetWithMetaTrait
19+
{
20+
public function getWithMeta($key): \Relay\Relay|array|false
21+
{
22+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getWithMeta(...\func_get_args());
23+
}
24+
}
25+
} else {
26+
/**
27+
* @internal
28+
*/
29+
trait GetWithMetaTrait
30+
{
31+
}
32+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Cache\Traits\Relay;
13+
14+
var_dump(phpversion('relay'));
15+
16+
if (version_compare(phpversion('relay'), '0.11.1', '>=')) {
17+
/**
18+
* @internal
19+
*/
20+
trait IsTrackedTrait
21+
{
22+
public function isTracked($key): bool
23+
{
24+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->isTracked(...\func_get_args());
25+
}
26+
}
27+
} else {
28+
/**
29+
* @internal
30+
*/
31+
trait IsTrackedTrait
32+
{
33+
}
34+
}
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Cache\Traits\Relay;
13+
14+
if (version_compare(phpversion('relay'), '0.11.0', '>=')) {
15+
/**
16+
* @internal
17+
*/
18+
trait Relay11Trait
19+
{
20+
public function cmsIncrBy($key, $field, $value, ...$fields_and_falues): \Relay\Relay|array|false
21+
{
22+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->cmsIncrBy(...\func_get_args());
23+
}
24+
25+
public function cmsInfo($key): \Relay\Relay|array|false
26+
{
27+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->cmsInfo(...\func_get_args());
28+
}
29+
30+
public function cmsInitByDim($key, $width, $depth): \Relay\Relay|bool
31+
{
32+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->cmsInitByDim(...\func_get_args());
33+
}
34+
35+
public function cmsInitByProb($key, $error, $probability): \Relay\Relay|bool
36+
{
37+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->cmsInitByProb(...\func_get_args());
38+
}
39+
40+
public function cmsMerge($dstkey, $keys, $weights = []): \Relay\Relay|bool
41+
{
42+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->cmsMerge(...\func_get_args());
43+
}
44+
45+
public function cmsQuery($key, ...$fields): \Relay\Relay|array|false
46+
{
47+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->cmsQuery(...\func_get_args());
48+
}
49+
50+
public function commandlog($subcmd, ...$args): \Relay\Relay|array|bool|int
51+
{
52+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->commandlog(...\func_get_args());
53+
}
54+
55+
public function hexpire($hash, $ttl, $fields, $mode = null): \Relay\Relay|array|false
56+
{
57+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hexpire(...\func_get_args());
58+
}
59+
60+
public function hexpireat($hash, $ttl, $fields, $mode = null): \Relay\Relay|array|false
61+
{
62+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hexpireat(...\func_get_args());
63+
}
64+
65+
public function hexpiretime($hash, $fields): \Relay\Relay|array|false
66+
{
67+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hexpiretime(...\func_get_args());
68+
}
69+
70+
public function hgetdel($key, $fields): \Relay\Relay|array|false
71+
{
72+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hgetdel(...\func_get_args());
73+
}
74+
75+
public function hgetex($hash, $fields, $expiry = null): \Relay\Relay|array|false
76+
{
77+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hgetex(...\func_get_args());
78+
}
79+
80+
public function hpersist($hash, $fields): \Relay\Relay|array|false
81+
{
82+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hpersist(...\func_get_args());
83+
}
84+
85+
public function hpexpire($hash, $ttl, $fields, $mode = null): \Relay\Relay|array|false
86+
{
87+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hpexpire(...\func_get_args());
88+
}
89+
90+
public function hpexpireat($hash, $ttl, $fields, $mode = null): \Relay\Relay|array|false
91+
{
92+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hpexpireat(...\func_get_args());
93+
}
94+
95+
public function hpexpiretime($hash, $fields): \Relay\Relay|array|false
96+
{
97+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hpexpiretime(...\func_get_args());
98+
}
99+
100+
public function hpttl($hash, $fields): \Relay\Relay|array|false
101+
{
102+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hpttl(...\func_get_args());
103+
}
104+
105+
public function hsetex($key, $fields, $expiry = null): \Relay\Relay|false|int
106+
{
107+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hsetex(...\func_get_args());
108+
}
109+
110+
public function httl($hash, $fields): \Relay\Relay|array|false
111+
{
112+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->httl(...\func_get_args());
113+
}
114+
115+
public function serverName(): false|string
116+
{
117+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->serverName(...\func_get_args());
118+
}
119+
120+
public function serverVersion(): false|string
121+
{
122+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->serverVersion(...\func_get_args());
123+
}
124+
}
125+
} else {
126+
/**
127+
* @internal
128+
*/
129+
trait Relay11Trait
130+
{
131+
}
132+
}

0 commit comments

Comments
 (0)
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