function ExpressionParser::getFunction
1 call to ExpressionParser::getFunction()
- ExpressionParser::getFunctionNode in vendor/
twig/ twig/ src/ ExpressionParser.php
File
-
vendor/
twig/ twig/ src/ ExpressionParser.php, line 803
Class
- ExpressionParser
- Parses expressions.
Namespace
TwigCode
private function getFunction(string $name, int $line) : TwigFunction {
if (!($function = $this->env
->getFunction($name))) {
if ($this->parser
->shouldIgnoreUnknownTwigCallables()) {
return new TwigFunction($name, fn() => '');
}
$e = new SyntaxError(\sprintf('Unknown "%s" function.', $name), $line, $this->parser
->getStream()
->getSourceContext());
$e->addSuggestions($name, array_keys($this->env
->getFunctions()));
throw $e;
}
if ($function->isDeprecated()) {
$src = $this->parser
->getStream()
->getSourceContext();
$function->triggerDeprecation($src->getPath() ?: $src->getName(), $line);
}
return $function;
}