10000 bug #52036 [Cache][VarExporter] Fix proxy generation to deal with edg… · symfony/symfony@21599a4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 21599a4

Browse files
bug #52036 [Cache][VarExporter] Fix proxy generation to deal with edgy behaviors of internal classes (nicolas-grekas)
This PR was merged into the 6.3 branch. Discussion ---------- [Cache][VarExporter] Fix proxy generation to deal with edgy behaviors of internal classes | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #51770, #51679, #51700 | License | MIT Instead of #51838 This fixes the issue by not passing default values explicitly when they were not provided during the call to the method. Commits ------- c66a2f7 [Cache][VarExporter] Fix proxy generation to deal with edgy behaviors of internal classes
2 parents 39a56d3 + c66a2f7 commit 21599a4

File tree

5 files changed

+21
-17
lines changed

5 files changed

+21
-17
lines changed

src/Symfony/Component/Cache/Traits/Redis6Proxy.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ public function hVals($key): \Redis|array|false
538538

539539
public function hscan($key, &$iterator, $pattern = null, $count = 0): \Redis|array|bool
540540
{
541-
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hscan($key, $iterator, $pattern, $count, ...\array_slice(\func_get_args(), 4));
541+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hscan($key, $iterator, ...\array_slice(\func_get_args(), 2));
542542
}
543543

544544
public function incr($key, $by = 1): \Redis|false|int
@@ -888,7 +888,7 @@ public function save(): \Redis|bool
888888

889889
public function scan(&$iterator, $pattern = null, $count = 0, $type = null): array|false
890890
{
891-
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->scan($iterator, $pattern, $count, $type, ...\array_slice(\func_get_args(), 4));
891+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->scan($iterator, ...\array_slice(\func_get_args(), 1));
892892
}
893893

894894
public function scard($key): \Redis|false|int
@@ -998,7 +998,7 @@ public function srem($key, $value, ...$other_values): \Redis|false|int
998998

999999
public function sscan($key, &$iterator, $pattern = null, $count = 0): array|false
10001000
{
1001-
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sscan($key, $iterator, $pattern, $count, ...\array_slice(\func_get_args(), 4));
1001+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sscan($key, $iterator, ...\array_slice(\func_get_args(), 2));
10021002
}
10031003

10041004
public function ssubscribe($channels, $cb): bool
@@ -1278,7 +1278,7 @@ public function zinterstore($dst, $keys, $weights = null, $aggregate = null): \R
12781278

12791279
public function zscan($key, &$iterator, $pattern = null, $count = 0): \Redis|array|false
12801280
{
1281-
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zscan($key, $iterator, $pattern, $count, ...\array_slice(\func_get_args(), 4));
1281+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zscan($key, $iterator, ...\array_slice(\func_get_args(), 2));
12821282
}
12831283

12841284
public function zunion($keys, $weights = null, $options = null): \Redis|array|false

src/Symfony/Component/Cache/Traits/RedisCluster6Proxy.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ public function hmset($key, $key_values): \RedisCluster|bool
463463

464464
public function hscan($key, &$iterator, $pattern = null, $count = 0): array|bool
465465
{
466-
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hscan($key, $iterator, $pattern, $count, ...\array_slice(\func_get_args(), 4));
466+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hscan($key, $iterator, ...\array_slice(\func_get_args(), 2));
467467
}
468468

469469
public function hrandfield($key, $options = null): \RedisCluster|array|string
@@ -738,7 +738,7 @@ public function save($key_or_address): \RedisCluster|bool
738738

739739
public function scan(&$iterator, $key_or_address, $pattern = null, $count = 0): array|bool
740740
{
741-
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->scan($iterator, $key_or_address, $pattern, $count, ...\array_slice(\func_get_args(), 4));
741+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->scan($iterator, ...\array_slice(\func_get_args(), 1));
742742
}
743743

744744
public function scard($key): \RedisCluster|false|int
@@ -858,7 +858,7 @@ public function srem($key, $value, ...$other_values): \RedisCluster|false|int
858858

859859
public function sscan($key, &$iterator, $pattern = null, $count = 0): array|false
860860
{
861-
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sscan($key, $iterator, $pattern, $count, ...\array_slice(\func_get_args(), 4));
861+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sscan($key, $iterator, ...\array_slice(\func_get_args(), 2));
862862
}
863863

864864
public function strlen($key): \RedisCluster|false|int
@@ -1103,7 +1103,7 @@ public function zrevrank($key, $member): \RedisCluster|false|int
11031103

11041104
public function zscan($key, &$iterator, $pattern = null, $count = 0): \RedisCluster|array|bool
11051105
{
1106-
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zscan($key, $iterator, $pattern, $count, ...\array_slice(\func_get_args(), 4));
1106+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zscan($key, $iterator, ...\array_slice(\func_get_args(), 2));
11071107
}
11081108

11091109
public function zscore($key, $member): \RedisCluster|false|float

src/Symfony/Component/Cache/Traits/RelayProxy.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -984,22 +984,22 @@ public function clearBytes(): void
984984

985985
public function scan(&$iterator, $match = null, $count = 0, $type = null): array|false
986986
{
987-
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->scan($iterator, $match, $count, $type, ...\array_slice(\func_get_args(), 4));
987+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->scan($iterator, ...\array_slice(\func_get_args(), 1));
988988
}
989989

990990
public function hscan($key, &$iterator, $match = null, $count = 0): array|false
991991
{
992-
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hscan($key, $iterator, $match, $count, ...\array_slice(\func_get_args(), 4));
992+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hscan($key, $iterator, ...\array_slice(\func_get_args(), 2));
993993
}
994994

995995
public function sscan($key, &$iterator, $match = null, $count = 0): array|false
996996
{
997-
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sscan($key, $iterator, $match, $count, ...\array_slice(\func_get_args(), 4));
997+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sscan($key, $iterator, ...\array_slice(\func_get_args(), 2));
998998
}
999999

10001000
public function zscan($key, &$iterator, $match = null, $count = 0): array|false
10011001
{
1002-
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zscan($key, $iterator, $match, $count, ...\array_slice(\func_get_args(), 4));
1002+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zscan($key, $iterator, ...\array_slice(\func_get_args(), 2));
10031003
}
10041004

10051005
public function keys($pattern): \Relay\Relay|array|false

src/Symfony/Component/Cache/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"psr/log": "^1.1|^2|^3",
2727
"symfony/cache-contracts": "^2.5|^3",
2828
"symfony/service-contracts": "^2.5|^3",
29-
"symfony/var-exporter": "^6.2.10"
29+
"symfony/var-exporter": "^6.3.6"
3030
},
3131
"require-dev": {
3232
"cache/integration-tests": "dev-master",

src/Symfony/Component/VarExporter/ProxyHelper.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class);
215215

216216
public static function exportSignature(\ReflectionFunctionAbstract $function, bool $withParameterTypes = true, string &$args = null): string
217217
{
218-
$hasByRef = false;
218+
$byRefIndex = 0;
219219
$args = '';
220220
$param = null;
221221
$parameters = [];
@@ -225,16 +225,20 @@ public static function exportSignature(\ReflectionFunctionAbstract $function, bo
225225
.($param->isPassedByReference() ? '&' : '')
226226
.($param->isVariadic() ? '...' : '').'$'.$param->name
227227
.($param->isOptional() && !$param->isVariadic() ? ' = '.self::exportDefault($param) : '');
228-
$hasByRef = $hasByRef || $param->isPassedByReference();
228+
if ($param->isPassedByReference()) {
229+
$byRefIndex = 1 + $param->getPosition();
230+
}
229231
$args .= ($param->isVariadic() ? '...$' : '$').$param->name.', ';
230232
}
231233

232-
if (!$param || !$hasByRef) {
234+
if (!$param || !$byRefIndex) {
233235
$args = '...\func_get_args()';
234236
} elseif ($param->isVariadic()) {
235237
$args = substr($args, 0, -2);
72BF
236238
} else {
237-
$args .= sprintf('...\array_slice(\func_get_args(), %d)', \count($parameters));
239+
$args = explode(', ', $args, 1 + $byRefIndex);
240+
$args[$byRefIndex] = sprintf('...\array_slice(\func_get_args(), %d)', $byRefIndex);
241+
$args = implode(', ', $args);
238242
}
239243

240244
$signature = 'function '.($function->returnsReference() ? '&' : '')

0 commit comments

Comments
 (0)
0