Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4c08b07

Browse filesBrowse files
committed
minor #29309 Optimize perf by replacing call_user_func with dynamic variables (ostrolucky)
This PR was merged into the 4.1 branch. Discussion ---------- Optimize perf by replacing call_user_func with dynamic variables | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | This provides similar boost as in #29245, but on more places and without complexity increase. Check eg. https://github.com/fab2s/call_user_func for proof Fabpot failure unrelated Commits ------- 0c6ef01 Optimize perf by replacing call_user_func with dynamic vars
2 parents c600de0 + 0c6ef01 commit 4c08b07
Copy full SHA for 4c08b07

File tree

54 files changed

+79
-79
lines changed
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner

54 files changed

+79
-79
lines changed

‎src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ public function configureOptions(OptionsResolver $resolver)
212212
// for equal query builders
213213
$queryBuilderNormalizer = function (Options $options, $queryBuilder) {
214214
if (\is_callable($queryBuilder)) {
215-
$queryBuilder = \call_user_func($queryBuilder, $options['em']->getRepository($options['class']));
215+
$queryBuilder = $queryBuilder($options['em']->getRepository($options['class']));
216216
}
217217

218218
return $queryBuilder;

‎src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function configureOptions(OptionsResolver $resolver)
2929
// for equal query builders
3030
$queryBuilderNormalizer = function (Options $options, $queryBuilder) {
3131
if (\is_callable($queryBuilder)) {
32-
$queryBuilder = \call_user_func($queryBuilder, $options['em']->getRepository($options['class']));
32+
$queryBuilder = $queryBuilder($options['em']->getRepository($options['class']));
3333

3434
if (null !== $queryBuilder && !$queryBuilder instanceof QueryBuilder) {
3535
throw new UnexpectedTypeException($queryBuilder, 'Doctrine\ORM\QueryBuilder');

‎src/Symfony/Bridge/Monolog/Handler/ServerLogHandler.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Monolog/Handler/ServerLogHandler.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ private function formatRecord(array $record)
102102
{
103103
if ($this->processors) {
104104
foreach ($this->processors as $processor) {
105-
$record = \call_user_func($processor, $record);
105+
$record = $processor($record);
106106
}
107107
}
108108

‎src/Symfony/Bridge/ProxyManager/LazyProxy/Instantiator/RuntimeInstantiator.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/ProxyManager/LazyProxy/Instantiator/RuntimeInstantiator.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function instantiateProxy(ContainerInterface $container, Definition $defi
5151
return $this->factory->createProxy(
5252
$definition->getClass(),
5353
function (&$wrappedInstance, LazyLoadingInterface $proxy) use ($realInstantiator) {
54-
$wrappedInstance = \call_user_func($realInstantiator);
54+
$wrappedInstance = $realInstantiator();
5555

5656
$proxy->setProxyInitializer(null);
5757

‎src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ class PhpArrayAdapterWrapper extends PhpArrayAdapter
122122
{
123123
public function save(CacheItemInterface $item)
124124
{
125-
\call_user_func(\Closure::bind(function () use ($item) {
125+
(\Closure::bind(function () use ($item) {
126126
$this->values[$item->getKey()] = $item->get();
127127
$this->warmUp($this->values);
128128
$this->values = eval(substr(file_get_contents($this->file), 6));
129-
}, $this, PhpArrayAdapter::class));
129+
}, $this, PhpArrayAdapter::class))();
130130

131131
return true;
132132
}

‎src/Symfony/Component/Cache/Tests/CacheItemTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Tests/CacheItemTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ public function testTag()
5959
$this->assertSame($item, $item->tag('foo'));
6060
$this->assertSame($item, $item->tag(array('bar', 'baz')));
6161

62-
\call_user_func(\Closure::bind(function () use ($item) {
62+
(\Closure::bind(function () use ($item) {
6363
$this->assertSame(array('foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz'), $item->tags);
64-
}, $this, CacheItem::class));
64+
}, $this, CacheItem::class))();
6565
}
6666

6767
/**

‎src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheTest.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ class PhpArrayCacheWrapper extends PhpArrayCache
116116
{
117117
public function set($key, $value, $ttl = null)
118118
{
119-
\call_user_func(\Closure::bind(function () use ($key, $value) {
119+
(\Closure::bind(function () use ($key, $value) {
120120
$this->values[$key] = $value;
121121
$this->warmUp($this->values);
122122
$this->values = eval(substr(file_get_contents($this->file), 6));
123-
}, $this, PhpArrayCache::class));
123+
}, $this, PhpArrayCache::class))();
124124

125125
return true;
126126
}
@@ -130,13 +130,13 @@ public function setMultiple($values, $ttl = null)
130130
if (!\is_array($values) && !$values instanceof \Traversable) {
131131
return parent::setMultiple($values, $ttl);
132132
}
133-
\call_user_func(\Closure::bind(function () use ($values) {
133+
(\Closure::bind(function () use ($values) {
134134
foreach ($values as $key => $value) {
135135
$this->values[$key] = $value;
136136
}
137137
$this->warmUp($this->values);
138138
$this->values = eval(substr(file_get_contents($this->file), 6));
139-
}, $this, PhpArrayCache::class));
139+
}, $this, PhpArrayCache::class))();
140140

141141
return true;
142142
}

‎src/Symfony/Component/Config/ConfigCacheFactory.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/ConfigCacheFactory.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function cache($file, $callback)
4343

4444
$cache = new ConfigCache($file, $this->debug);
4545
if (!$cache->isFresh()) {
46-
\call_user_func($callback, $cache);
46+
$callback($cache);
4747
}
4848

4949
return $cache;

‎src/Symfony/Component/Config/Resource/ReflectionClassResource.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Resource/ReflectionClassResource.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,12 @@ private function generateSignature(\ReflectionClass $class)
154154

155155
if (interface_exists(EventSubscriberInterface::class, false) && $class->isSubclassOf(EventSubscriberInterface::class)) {
156156
yield EventSubscriberInterface::class;
157-
yield print_r(\call_user_func(array($class->name, 'getSubscribedEvents')), true);
157+
yield print_r($class->name::getSubscribedEvents(), true);
158158
}
159159

160160
if (interface_exists(ServiceSubscriberInterface::class, false) && $class->isSubclassOf(ServiceSubscriberInterface::class)) {
161161
yield ServiceSubscriberInterface::class;
162-
yield print_r(\call_user_func(array($class->name, 'getSubscribedServices')), true);
162+
yield print_r($class->name::getSubscribedServices(), true);
163163
}
164164
}
165165
}

‎src/Symfony/Component/Config/ResourceCheckerConfigCacheFactory.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/ResourceCheckerConfigCacheFactory.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function cache($file, $callback)
4040

4141
$cache = new ResourceCheckerConfigCache($file, $this->resourceCheckers);
4242
if (!$cache->isFresh()) {
43-
\call_user_func($callback, $cache);
43+
$callback($cache);
4444
}
4545

4646
return $cache;

‎src/Symfony/Component/Config/Util/XmlUtils.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Util/XmlUtils.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public static function parse($content, $schemaOrCallable = null)
8080
$e = null;
8181
if (\is_callable($schemaOrCallable)) {
8282
try {
83-
$valid = \call_user_func($schemaOrCallable, $dom, $internalErrors);
83+
$valid = $schemaOrCallable($dom, $internalErrors);
8484
} catch (\Exception $e) {
8585
$valid = false;
8686
}

‎src/Symfony/Component/Console/Command/Command.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Command/Command.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ public function run(InputInterface $input, OutputInterface $output)
250250
$input->validate();
251251

252252
if ($this->code) {
253-
$statusCode = \call_user_func($this->code, $input, $output);
253+
$statusCode = ($this->code)($input, $output);
254254
} else {
255255
$statusCode = $this->execute($input, $output);
256256
}

‎src/Symfony/Component/Console/Helper/ProcessHelper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Helper/ProcessHelper.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function wrapCallback(OutputInterface $output, Process $process, callable
121121
$output->write($formatter->progress(spl_object_hash($process), $this->escapeString($buffer), Process::ERR === $type));
122122

123123
if (null !== $callback) {
124-
\call_user_func($callback, $type, $buffer);
124+
$callback($type, $buffer);
125125
}
126126
};
127127
}

‎src/Symfony/Component/Console/Helper/ProgressBar.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Helper/ProgressBar.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ private function buildLine(): string
496496
$regex = "{%([a-z\-_]+)(?:\:([^%]+))?%}i";
497497
$callback = function ($matches) {
498498
if ($formatter = $this::getPlaceholderFormatterDefinition($matches[1])) {
499-
$text = \call_user_func($formatter, $this, $this->output);
499+
$text = $formatter($this, $this->output);
500500
} elseif (isset($this->messages[$matches[1]])) {
501501
$text = $this->messages[$matches[1]];
502502
} else {

‎src/Symfony/Component/Console/Helper/ProgressIndicator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Helper/ProgressIndicator.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ private function display()
196196

197197
$this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) use ($self) {
198198
if ($formatter = $self::getPlaceholderFormatterDefinition($matches[1])) {
199-
return \call_user_func($formatter, $self);
199+
return $formatter($self);
200200
}
201201

202202
return $matches[0];

‎src/Symfony/Component/Console/Helper/QuestionHelper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Helper/QuestionHelper.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ private function validateAttempts(callable $interviewer, OutputInterface $output
381381
}
382382

383383
try {
384-
return \call_user_func($question->getValidator(), $interviewer());
384+
return $question->getValidator()($interviewer());
385385
} catch (RuntimeException $e) {
386386
throw $e;
387387
} catch (\Exception $error) {

‎src/Symfony/Component/CssSelector/XPath/Translator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/CssSelector/XPath/Translator.php
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public function nodeToXPath(NodeInterface $node): XPathExpr
155155
throw new ExpressionErrorException(sprintf('Node "%s" not supported.', $node->getNodeName()));
156156
}
157157

158-
return \call_user_func($this->nodeTranslators[$node->getNodeName()], $node, $this);
158+
return $this->nodeTranslators[$node->getNodeName()]($node, $this);
159159
}
160160

161161
/**
@@ -167,7 +167,7 @@ public function addCombination(string $combiner, NodeInterface $xpath, NodeInter
167167
throw new ExpressionErrorException(sprintf('Combiner "%s" not supported.', $combiner));
168168
}
169169

170-
return \call_user_func($this->combinationTranslators[$combiner], $this->nodeToXPath($xpath), $this->nodeToXPath($combinedXpath));
170+
return $this->combinationTranslators[$combiner]($this->nodeToXPath($xpath), $this->nodeToXPath($combinedXpath));
171171
}
172172

173173
/**
@@ -179,7 +179,7 @@ public function addFunction(XPathExpr $xpath, FunctionNode $function): XPathExpr
179179
throw new ExpressionErrorException(sprintf('Function "%s" not supported.', $function->getName()));
180180
}
181181

182-
return \call_user_func($this->functionTranslators[$function->getName()], $xpath, $function);
182+
return $this->functionTranslators[$function->getName()]($xpath, $function);
183183
}
184184

185185
/**
@@ -191,7 +191,7 @@ public function addPseudoClass(XPathExpr $xpath, string $pseudoClass): XPathExpr
191191
throw new ExpressionErrorException(sprintf('Pseudo-class "%s" not supported.', $pseudoClass));
192192
}
193193

194-
return \call_user_func($this->pseudoClassTranslators[$pseudoClass], $xpath);
194+
return $this->pseudoClassTranslators[$pseudoClass]($xpath);
195195
}
196196

197197
/**
@@ -203,7 +203,7 @@ public function addAttributeMatching(XPathExpr $xpath, string $operator, string
203203
throw new ExpressionErrorException(sprintf('Attribute matcher operator "%s" not supported.', $operator));
204204
}
205205

206-
return \call_user_func($this->attributeMatchingTranslators[$operator], $xpath, $attribute, $value);
206+
return $this->attributeMatchingTranslators[$operator]($xpath, $attribute, $value);
207207
}
208208

209209
/**

‎src/Symfony/Component/Debug/DebugClassLoader.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Debug/DebugClassLoader.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public function loadClass($class)
147147
require $file;
148148
}
149149
} else {
150-
\call_user_func($this->classLoader, $class);
150+
($this->classLoader)($class);
151151
$file = false;
152152
}
153153
} finally {

‎src/Symfony/Component/Debug/ErrorHandler.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Debug/ErrorHandler.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ public function handleException($exception, array $error = null)
553553
$this->exceptionHandler = null;
554554
try {
555555
if (null !== $exceptionHandler) {
556-
return \call_user_func($exceptionHandler, $exception);
556+
return $exceptionHandler($exception);
557557
}
558558
$handlerException = $handlerException ?: $exception;
559559
} catch (\Throwable $handlerException) {

‎src/Symfony/Component/Debug/ExceptionHandler.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Debug/ExceptionHandler.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public function handle(\Exception $exception)
142142
$this->caughtBuffer = null;
143143

144144
try {
145-
\call_user_func($this->handler, $exception);
145+
($this->handler)($exception);
146146
$this->caughtLength = $caughtLength;
147147
} catch (\Exception $e) {
148148
if (!$caughtLength) {

‎src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/ContainerBuilder.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ private function createService(Definition $definition, array &$inlineServices, $
11601160
throw new InvalidArgumentException(sprintf('The configure callable for class "%s" is not a callable.', \get_class($service)));
11611161
}
11621162

1163-
\call_user_func($callable, $service);
1163+
$callable($service);
11641164
}
11651165

11661166
return $service;

‎src/Symfony/Component/DependencyInjection/LazyProxy/Instantiator/RealServiceInstantiator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/LazyProxy/Instantiator/RealServiceInstantiator.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ class RealServiceInstantiator implements InstantiatorInterface
2828
*/
2929
public function instantiateProxy(ContainerInterface $container, Definition $definition, $id, $realInstantiator)
3030
{
31-
return \call_user_func($realInstantiator);
31+
return $realInstantiator();
3232
}
3333
}

‎src/Symfony/Component/DependencyInjection/Loader/ClosureLoader.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/ClosureLoader.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function __construct(ContainerBuilder $container)
3535
*/
3636
public function load($resource, $type = null)
3737
{
38-
\call_user_func($resource, $this->container);
38+
$resource($this->container);
3939
}
4040

4141
/**

‎src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function __invoke(Event $event, $eventName, EventDispatcherInterface $dis
108108

109109
$e = $this->stopwatch->start($this->name, 'event_listener');
110110

111-
\call_user_func($this->listener, $event, $eventName, $this->dispatcher ?: $dispatcher);
111+
($this->listener)($event, $eventName, $this->dispatcher ?: $dispatcher);
112112

113113
if ($e->isStarted()) {
114114
$e->stop();

‎src/Symfony/Component/EventDispatcher/EventDispatcher.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/EventDispatcher/EventDispatcher.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ protected function doDispatch($listeners, $eventName, Event $event)
209209
if ($event->isPropagationStopped()) {
210210
break;
211211
}
212-
\call_user_func($listener, $event, $eventName, $this);
212+
$listener($event, $eventName, $this);
213213
}
214214
}
215215

‎src/Symfony/Component/Finder/Iterator/CustomFilterIterator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Iterator/CustomFilterIterator.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function accept()
5151
$fileinfo = $this->current();
5252

5353
foreach ($this->filters as $filter) {
54-
if (false === \call_user_func($filter, $fileinfo)) {
54+
if (false === $filter($fileinfo)) {
5555
return false;
5656
}
5757
}

‎src/Symfony/Component/Form/CallbackTransformer.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/CallbackTransformer.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function __construct(callable $transform, callable $reverseTransform)
4141
*/
4242
public function transform($data)
4343
{
44-
return \call_user_func($this->transform, $data);
44+
return ($this->transform)($data);
4545
}
4646

4747
/**
@@ -57,6 +57,6 @@ public function transform($data)
5757
*/
5858
public function reverseTransform($data)
5959
{
60-
return \call_user_func($this->reverseTransform, $data);
60+
return ($this->reverseTransform)($data);
6161
}
6262
}

‎src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public function getValuesForChoices(array $choices)
155155
$givenValues = array();
156156

157157
foreach ($choices as $i => $givenChoice) {
158-
$givenValues[$i] = (string) \call_user_func($this->valueCallback, $givenChoice);
158+
$givenValues[$i] = (string) ($this->valueCallback)($givenChoice);
159159
}
160160

161161
return array_intersect($givenValues, array_keys($this->choices));
@@ -202,7 +202,7 @@ protected function flatten(array $choices, $value, &$choicesByValues, &$keysByVa
202202
continue;
203203
}
204204

205-
$choiceValue = (string) \call_user_func($value, $choice);
205+
$choiceValue = (string) $value($choice);
206206
$choicesByValues[$choiceValue] = $choice;
207207
$keysByValues[$choiceValue] = $key;
208208
$structuredValues[$key] = $choiceValue;

‎src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ private static function addChoiceView($choice, $value, $label, $keys, &$index, $
118118
// $value may be an integer or a string, since it's stored in the array
119119
// keys. We want to guarantee it's a string though.
120120
$key = $keys[$value];
121-
$nextIndex = \is_int($index) ? $index++ : \call_user_func($index, $choice, $key, $value);
121+
$nextIndex = \is_int($index) ? $index++ : $index($choice, $key, $value);
122122

123123
// BC normalize label to accept a false value
124124
if (null === $label) {
@@ -127,7 +127,7 @@ private static function addChoiceView($choice, $value, $label, $keys, &$index, $
127127
} elseif (false !== $label) {
128128
// If "choice_label" is set to false and "expanded" is true, the value false
129129
// should be passed on to the "label" option of the checkboxes/radio buttons
130-
$dynamicLabel = \call_user_func($label, $choice, $key, $value);
130+
$dynamicLabel = $label($choice, $key, $value);
131131
$label = false === $dynamicLabel ? false : (string) $dynamicLabel;
132132
}
133133

@@ -137,11 +137,11 @@ private static function addChoiceView($choice, $value, $label, $keys, &$index, $
137137
$label,
138138
// The attributes may be a callable or a mapping from choice indices
139139
// to nested arrays
140-
\is_callable($attr) ? \call_user_func($attr, $choice, $key, $value) : (isset($attr[$key]) ? $attr[$key] : array())
140+
\is_callable($attr) ? $attr($choice, $key, $value) : (isset($attr[$key]) ? $attr[$key] : array())
141141
);
142142

143143
// $isPreferred may be null if no choices are preferred
144-
if ($isPreferred && \call_user_func($isPreferred, $choice, $key, $value)) {
144+
if ($isPreferred && $isPreferred($choice, $key, $value)) {
145145
$preferredViews[$nextIndex] = $view;
146146
} else {
147147
$otherViews[$nextIndex] = $view;
@@ -200,7 +200,7 @@ private static function addChoiceViewsGroupedBy($groupBy, $label, $choices, $key
200200

201201
private static function addChoiceViewGroupedBy($groupBy, $choice, $value, $label, $keys, &$index, $attr, $isPreferred, &$preferredViews, &$otherViews)
202202
{
203-
$groupLabel = \call_user_func($groupBy, $choice, $keys[$value], $value);
203+
$groupLabel = $groupBy($choice, $keys[$value], $value);
204204

205205
if (null === $groupLabel) {
206206
// If the callable returns null, don't group the choice

‎src/Symfony/Component/Form/ChoiceList/Loader/CallbackChoiceLoader.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/ChoiceList/Loader/CallbackChoiceLoader.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function loadChoiceList($value = null)
4646
return $this->choiceList;
4747
}
4848

49-
return $this->choiceList = new ArrayChoiceList(\call_user_func($this->callback), $value);
49+
return $this->choiceList = new ArrayChoiceList(($this->callback)(), $value);
5050
}
5151

5252
/**

‎src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public function onSubmit(FormEvent $event)
135135
/** @var FormInterface $child */
136136
foreach ($form as $name => $child) {
137137
$isNew = !isset($previousData[$name]);
138-
$isEmpty = \is_callable($this->deleteEmpty) ? \call_user_func($this->deleteEmpty, $child->getData()) : $child->isEmpty();
138+
$isEmpty = \is_callable($this->deleteEmpty) ? ($this->deleteEmpty)($child->getData()) : $child->isEmpty();
139139

140140
// $isNew can only be true if allowAdd is true, so we don't
141141
// need to check allowAdd again

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.