function ExpressionParser::getFunctionNode
1 call to ExpressionParser::getFunctionNode()
- ExpressionParser::parsePrimaryExpression in vendor/
twig/ twig/ src/ ExpressionParser.php
File
-
vendor/
twig/ twig/ src/ ExpressionParser.php, line 533
Class
- ExpressionParser
- Parses expressions.
Namespace
TwigCode
public function getFunctionNode($name, $line) {
if (null !== ($alias = $this->parser
->getImportedSymbol('function', $name))) {
return new MacroReferenceExpression($alias['node']->getNode('var'), $alias['name'], $this->createArguments($line), $line);
}
$args = $this->parseOnlyArguments();
$function = $this->getFunction($name, $line);
if ($function->getParserCallable()) {
$fakeNode = new EmptyNode($line);
$fakeNode->setSourceContext($this->parser
->getStream()
->getSourceContext());
return $function->getParserCallable()($this->parser, $fakeNode, $args, $line);
}
if (!isset($this->readyNodes[$class = $function->getNodeClass()])) {
$this->readyNodes[$class] = (bool) (new \ReflectionClass($class))->getConstructor()
->getAttributes(FirstClassTwigCallableReady::class);
}
if (!($ready = $this->readyNodes[$class])) {
trigger_deprecation('twig/twig', '3.12', 'Twig node "%s" is not marked as ready for passing a "TwigFunction" in the constructor instead of its name; please update your code and then add #[FirstClassTwigCallableReady] attribute to the constructor.', $class);
}
return new $class($ready ? $function : $function->getName(), $args, $line);
}