Skip to content

Commit fe6d1ee

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

File tree

7 files changed

+373
-3
lines changed

7 files changed

+373
-3
lines changed

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: 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.9.0', '>=')) {
15+
/**
16+
* @internal
17+
*/
18+
trait FtTrait
19+
{
20+
public function ftAggregate($index, $query, $options = null): \Relay\Relay|array|false
21+
{
22+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftAggregate(...\func_get_args());
23+
}
24+
25+
public function ftAliasAdd($index, $alias): \Relay\Relay|bool
26+
{
27+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftAliasAdd(...\func_get_args());
28+
}
29+
30+
public function ftAliasDel($alias): \Relay\Relay|bool
31+
{
32+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftAliasDel(...\func_get_args());
33+
}
34+
35+
public function ftAliasUpdate($index, $alias): \Relay\Relay|bool
36+
{
37+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftAliasUpdate(...\func_get_args());
38+
}
39+
40+
public function ftAlter($index, $schema, $skipinitialscan = false): \Relay\Relay|bool
41+
{
42+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftAlter(...\func_get_args());
43+
}
44+
45+
public function ftConfig($operation, $option, $value = null): \Relay\Relay|array|bool
46+
{
47+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftConfig(...\func_get_args());
48+
}
49+
50+
public function ftCreate($index, $schema, $options = null): \Relay\Relay|bool
51+
{
52+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftCreate(...\func_get_args());
53+
}
54+
55+
public function ftCursor($operation, $index, $cursor, $options = null): \Relay\Relay|array|bool
56+
{
57+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftCursor(...\func_get_args());
58+
}
59+
60+
public function ftDictAdd($dict, $term, ...$other_terms): \Relay\Relay|false|int
61+
{
62+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftDictAdd(...\func_get_args());
63+
}
64+
65+
public function ftDictDel($dict, $term, ...$other_terms): \Relay\Relay|false|int
66+
{
67+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftDictDel(...\func_get_args());
68+
}
69+
70+
public function ftDictDump($dict): \Relay\Relay|array|false
71+
{
72+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftDictDump(...\func_get_args());
73+
}
74+
75+
public function ftDropIndex($index, $dd = false): \Relay\Relay|bool
76+
{
77+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftDropIndex(...\func_get_args());
78+
}
79+
80+
public function ftExplain($index, $query, $dialect = 0): \Relay\Relay|false|string
81+
{
82+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftExplain(...\func_get_args());
83+
}
84+
85+
public function ftExplainCli($index, $query, $dialect = 0): \Relay\Relay|array|false
86+
{
87+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftExplainCli(...\func_get_args());
88+
}
89+
90+
public function ftInfo($index): \Relay\Relay|array|false
91+
{
92+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftInfo(...\func_get_args());
93+
}
94+
95+
public function ftProfile($index, $command, $query, $limited = false): \Relay\Relay|array|false
96+
{
97+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftProfile(...\func_get_args());
98+
}
99+
100+
public function ftSearch($index, $query, $options = null): \Relay\Relay|array|false
101+
{
102+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftSearch(...\func_get_args());
103+
}
104+
105+
public function ftSpellCheck($index, $query, $options = null): \Relay\Relay|array|false
106+
{
107+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftSpellCheck(...\func_get_args());
108+
}
109+
110+
public function ftSynDump($index): \Relay\Relay|array|false
111+
{
112+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftSynDump(...\func_get_args());
113+
}
114+
115+
public function ftSynUpdate($index, $synonym, $term_or_terms, $skipinitialscan = false): \Relay\Relay|bool
116+
{
117+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftSynUpdate(...\func_get_args());
118+
}
119+
120+
public function ftTagVals($index, $tag): \Relay\Relay|array|false
121+
{
122+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftTagVals(...\func_get_args());
123+
}
124+
}
125+
} else {
126+
/**
127+
* @internal
128+
*/
129+
trait FtTrait
130+
{
131+
}
132+
}
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: 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.11.1', '>=')) {
15+
/**
16+
* @internal
17+
*/
18+
trait IsTrackedTrait
19+
{
20+
public function isTracked($key): bool
21+
{
22+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->isTracked(...\func_get_args());
23+
}
24+
}
25+
} else {
26+
/**
27+
* @internal
28+
*/
29+
trait IsTrackedTrait
30+
{
31+
}
32+
}
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+
}
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.9.0', '>=')) {
15+
/**
16+
* @internal
17+
*/
18+
trait SwapdbTrait
19+
{
20+
public function swapdb($index1, $index2): \Relay\Relay|bool
21+
{
22+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->swapdb(...\func_get_args());
23+
}
24+
}
25+
} else {
26+
/**
27+
* @internal
28+
*/
29+
trait SwapdbTrait
30+
{
31+
}
32+
}

0 commit comments

Comments
 (0)