Skip to content

Commit fd266c7

Browse files
Remove all calls to call_user_func()
1 parent 1277c49 commit fd266c7

File tree

33 files changed

+68
-59
lines changed

33 files changed

+68
-59
lines changed

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

Lines 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/Config/Util/XmlUtils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public static function loadFile($file, $schemaOrCallable = null)
7575
$e = null;
7676
if (is_callable($schemaOrCallable)) {
7777
try {
78-
$valid = call_user_func($schemaOrCallable, $dom, $internalErrors);
78+
$valid = $schemaOrCallable($dom, $internalErrors);
7979
} catch (\Exception $e) {
8080
$valid = false;
8181
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ public function run(InputInterface $input, OutputInterface $output)
246246

247247
$input->validate();
248248

249-
if ($this->code) {
250-
$statusCode = call_user_func($this->code, $input, $output);
249+
if ($code = $this->code) {
250+
$statusCode = $code($input, $output);
251251
} else {
252252
$statusCode = $this->execute($input, $output);
253253
}

src/Symfony/Component/Console/Helper/DialogHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ private function validateAttempts($interviewer, OutputInterface $output, $valida
467467
}
468468

469469
try {
470-
return call_user_func($validator, $interviewer());
470+
return $validator($interviewer());
471471
} catch (\Exception $error) {
472472
}
473473
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public function wrapCallback(OutputInterface $output, Process $process, $callbac
117117
$output->write($formatter->progress(spl_object_hash($process), $that->escapeString($buffer), Process::ERR === $type));
118118

119119
if (null !== $callback) {
120-
call_user_func($callback, $type, $buffer);
120+
$callback($type, $buffer);
121121
}
122122
};
123123
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ public function display()
438438
$messages = $this->messages;
439439
$this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) use ($self, $output, $messages) {
440440
if ($formatter = $self::getPlaceholderFormatterDefinition($matches[1])) {
441-
$text = call_user_func($formatter, $self, $output);
441+
$text = $formatter($self, $output);
442442
} elseif (isset($messages[$matches[1]])) {
443443
$text = $messages[$matches[1]];
444444
} else {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,13 +353,14 @@ private function validateAttempts($interviewer, OutputInterface $output, Questio
353353
{
354354
$error = null;
355355
$attempts = $question->getMaxAttempts();
356+
$validator = $question->getValidator();
356357
while (null === $attempts || $attempts--) {
357358
if (null !== $error) {
358359
$output->writeln($this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error'));
359360
}
360361

361362
try {
362-
return call_user_func($question->getValidator(), $interviewer());
363+
return $validator($interviewer());
363364
} catch (\Exception $error) {
364365
}
365366
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public function nodeToXPath(NodeInterface $node)
205205
throw new ExpressionErrorException(sprintf('Node "%s" not supported.', $node->getNodeName()));
206206
}
207207

208-
return call_user_func($this->nodeTranslators[$node->getNodeName()], $node, $this);
208+
return $this->nodeTranslators[$node->getNodeName()]($node, $this);
209209
}
210210

211211
/**
@@ -223,7 +223,7 @@ public function addCombination($combiner, NodeInterface $xpath, NodeInterface $c
223223
throw new ExpressionErrorException(sprintf('Combiner "%s" not supported.', $combiner));
224224
}
225225

226-
return call_user_func($this->combinationTranslators[$combiner], $this->nodeToXPath($xpath), $this->nodeToXPath($combinedXpath));
226+
return $this->combinationTranslators[$combiner]($this->nodeToXPath($xpath), $this->nodeToXPath($combinedXpath));
227227
}
228228

229229
/**
@@ -240,7 +240,7 @@ public function addFunction(XPathExpr $xpath, FunctionNode $function)
240240
throw new ExpressionErrorException(sprintf('Function "%s" not supported.', $function->getName()));
241241
}
242242

243-
return call_user_func($this->functionTranslators[$function->getName()], $xpath, $function);
243+
return $this->functionTranslators[$function->getName()]($xpath, $function);
244244
}
245245

246246
/**
@@ -257,7 +257,7 @@ public function addPseudoClass(XPathExpr $xpath, $pseudoClass)
257257
throw new ExpressionErrorException(sprintf('Pseudo-class "%s" not supported.', $pseudoClass));
258258
}
259259

260-
return call_user_func($this->pseudoClassTranslators[$pseudoClass], $xpath);
260+
return $this->pseudoClassTranslators[$pseudoClass]($xpath);
261261
}
262262

263263
/**
@@ -276,7 +276,7 @@ public function addAttributeMatching(XPathExpr $xpath, $operator, $attribute, $v
276276
throw new ExpressionErrorException(sprintf('Attribute matcher operator "%s" not supported.', $operator));
277277
}
278278

279-
return call_user_func($this->attributeMatchingTranslators[$operator], $xpath, $attribute, $value);
279+
return $this->attributeMatchingTranslators[$operator]($xpath, $attribute, $value);
280280
}
281281

282282
/**

src/Symfony/Component/Debug/DebugClassLoader.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,13 @@ public function loadClass($class)
150150
ErrorHandler::stackErrors();
151151

152152
try {
153+
$classLoader = $this->classLoader;
153154
if ($this->isFinder) {
154-
if ($file = $this->classLoader[0]->findFile($class)) {
155+
if ($file = $classLoader[0]->findFile($class)) {
155156
require $file;
156157
}
157158
} else {
158-
call_user_func($this->classLoader, $class);
159+
$classLoader($class);
159160
$file = false;
160161
}
161162
} catch (\Exception $e) {

src/Symfony/Component/Debug/ErrorHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,11 +466,11 @@ public function handleException(\Exception $exception, array $error = null)
466466
}
467467
}
468468
}
469-
if (empty($this->exceptionHandler)) {
469+
if (!$exceptionHandler = $this->exceptionHandler) {
470470
throw $exception; // Give back $exception to the native handler
471471
}
472472
try {
473-
call_user_func($this->exceptionHandler, $exception);
473+
$exceptionHandler($exception);
474474
} catch (\Exception $handlerException) {
475475
$this->exceptionHandler = null;
476476
$this->handleException($handlerException);

0 commit comments

Comments
 (0)