Skip to content

Commit b2718d7

Browse files
Remove all usages of call_user_func_array()
1 parent deae538 commit b2718d7

File tree

27 files changed

+38
-41
lines changed

27 files changed

+38
-41
lines changed

src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ private function findAndSortTags($tagName, ContainerBuilder $container)
146146

147147
if ($sortedTags) {
148148
krsort($sortedTags);
149-
$sortedTags = \call_user_func_array('array_merge', $sortedTags);
149+
$sortedTags = array_merge(...$sortedTags);
150150
}
151151

152152
return $sortedTags;

src/Symfony/Bridge/Monolog/Logger.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
use Symfony\Contracts\Service\ResetInterface;
1818

1919
/**
20-
* Logger.
21-
*
2220
* @author Fabien Potencier <fabien@symfony.com>
2321
*/
2422
class Logger extends BaseLogger implements DebugLoggerInterface, ResetInterface
@@ -29,7 +27,7 @@ class Logger extends BaseLogger implements DebugLoggerInterface, ResetInterface
2927
public function getLogs(/* Request $request = null */)
3028
{
3129
if ($logger = $this->getDebugLogger()) {
32-
return \call_user_func_array(array($logger, 'getLogs'), \func_get_args());
30+
return $logger->getLogs(...\func_get_args());
3331
}
3432

3533
return array();
@@ -41,7 +39,7 @@ public function getLogs(/* Request $request = null */)
4139
public function countErrors(/* Request $request = null */)
4240
{
4341
if ($logger = $this->getDebugLogger()) {
44-
return \call_user_func_array(array($logger, 'countErrors'), \func_get_args());
42+
return $logger->countErrors(...\func_get_args());
4543
}
4644

4745
return 0;

src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function testDump($context, $args, $expectedOutput, $debug = true)
7676
array_unshift($args, $context);
7777
array_unshift($args, $twig);
7878

79-
$dump = \call_user_func_array(array($extension, 'dump'), $args);
79+
$dump = $extension->dump(...$args);
8080

8181
if ($debug) {
8282
$this->assertStringStartsWith('<script>', $dump);

src/Symfony/Bundle/FrameworkBundle/Templating/Helper/StopwatchHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __call($method, $arguments = array())
3737
{
3838
if (null !== $this->stopwatch) {
3939
if (method_exists($this->stopwatch, $method)) {
40-
return \call_user_func_array(array($this->stopwatch, $method), $arguments);
40+
return $this->stopwatch->{$method}(...$arguments);
4141
}
4242

4343
throw new \BadMethodCallException(sprintf('Method "%s" of Stopwatch does not exist', $method));

src/Symfony/Bundle/SecurityBundle/Debug/WrappedListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function handle(GetResponseEvent $event)
5353
*/
5454
public function __call($method, $arguments)
5555
{
56-
return \call_user_func_array(array($this->listener, $method), $arguments);
56+
return $this->listener->{$method}(...$arguments);
5757
}
5858

5959
public function getWrappedListener(): ListenerInterface

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __call($method, array $args)
3232
{
3333
$this->ready ?: $this->ready = $this->initializer->__invoke($this->redis);
3434

35-
return \call_user_func_array(array($this->redis, $method), $args);
35+
return $this->redis->{$method}(...$args);
3636
}
3737

3838
public function hscan($strKey, &$iIterator, $strPattern = null, $iCount = null)

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,13 +336,13 @@ private function pipeline(\Closure $generator)
336336
// see https://github.com/nrk/predis/issues/267#issuecomment-123781423
337337
$results = array();
338338
foreach ($generator() as $command => $args) {
339-
$results[] = \call_user_func_array(array($this->redis, $command), $args);
339+
$results[] = $this->redis->{$command}(...$args);
340340
$ids[] = $args[0];
341341
}
342342
} elseif ($this->redis instanceof \Predis\Client) {
343343
$results = $this->redis->pipeline(function ($redis) use ($generator, &$ids) {
344344
foreach ($generator() as $command => $args) {
345-
\call_user_func_array(array($redis, $command), $args);
345+
$redis->{$command}(...$args);
346346
$ids[] = $args[0];
347347
}
348348
});
@@ -353,7 +353,7 @@ private function pipeline(\Closure $generator)
353353
$connections[$h] = array($this->redis->_instance($h), -1);
354354
$connections[$h][0]->multi(\Redis::PIPELINE);
355355
}
356-
\call_user_func_array(array($connections[$h][0], $command), $args);
356+
$connections[$h][0]->{$command}(...$args);
357357
$results[] = array($h, ++$connections[$h][1]);
358358
$ids[] = $args[0];
359359
}
@@ -366,7 +366,7 @@ private function pipeline(\Closure $generator)
366366
} else {
367367
$this->redis->multi(\Redis::PIPELINE);
368368
foreach ($generator() as $command => $args) {
369-
\call_user_func_array(array($this->redis, $command), $args);
369+
$this->redis->{$command}(...$args);
370370
$ids[] = $args[0];
371371
}
372372
$results = $this->redis->exec();

src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function testPrototypeNodeSpecificOption($method, $args)
4343
{
4444
$node = new ArrayNodeDefinition('root');
4545

46-
\call_user_func_array(array($node, $method), $args);
46+
$node->{$method}(...$args);
4747

4848
$node->getNode();
4949
}

src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,7 @@ private function createService(Definition $definition, array &$inlineServices, $
11141114
}
11151115

11161116
if (null !== $factory) {
1117-
$service = \call_user_func_array($factory, $arguments);
1117+
$service = $factory(...$arguments);
11181118

11191119
if (!$definition->isDeprecated() && \is_array($factory) && \is_string($factory[0])) {
11201120
$r = new \ReflectionClass($factory[0]);
@@ -1563,7 +1563,7 @@ private function callMethod($service, $call, array &$inlineServices)
15631563
}
15641564
}
15651565

1566-
\call_user_func_array(array($service, $call[0]), $this->doResolveServices($this->getParameterBag()->unescapeValue($this->getParameterBag()->resolveValue($call[1])), $inlineServices));
1566+
$service->{$call[0]}(...$this->doResolveServices($this->getParameterBag()->unescapeValue($this->getParameterBag()->resolveValue($call[1])), $inlineServices));
15671567
}
15681568

15691569
/**

src/Symfony/Component/DependencyInjection/Loader/Configurator/AbstractConfigurator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ abstract class AbstractConfigurator
2828
public function __call($method, $args)
2929
{
3030
if (method_exists($this, 'set'.$method)) {
31-
return \call_user_func_array(array($this, 'set'.$method), $args);
31+
return $this->{'set'.$method}(...$args);
3232
}
3333

3434
throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s()', \get_class($this), $method));

0 commit comments

Comments
 (0)