You are here

protected function Twig_ExpressionParser::getFunctionNodeClass in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/twig/twig/lib/Twig/ExpressionParser.php \Twig_ExpressionParser::getFunctionNodeClass()
1 call to Twig_ExpressionParser::getFunctionNodeClass()
Twig_ExpressionParser::getFunctionNode in vendor/twig/twig/lib/Twig/ExpressionParser.php

File

vendor/twig/twig/lib/Twig/ExpressionParser.php, line 568

Class

Twig_ExpressionParser
Parses expressions.

Code

protected function getFunctionNodeClass($name, $line) {
  $env = $this->parser
    ->getEnvironment();
  if (false === ($function = $env
    ->getFunction($name))) {
    $e = new Twig_Error_Syntax(sprintf('Unknown "%s" function.', $name), $line, $this->parser
      ->getFilename());
    $e
      ->addSuggestions($name, array_keys($env
      ->getFunctions()));
    throw $e;
  }
  if ($function instanceof Twig_SimpleFunction && $function
    ->isDeprecated()) {
    $message = sprintf('Twig Function "%s" is deprecated', $function
      ->getName());
    if ($function
      ->getAlternative()) {
      $message .= sprintf('. Use "%s" instead', $function
        ->getAlternative());
    }
    $message .= sprintf(' in %s at line %d.', $this->parser
      ->getFilename(), $line);
    @trigger_error($message, E_USER_DEPRECATED);
  }
  if ($function instanceof Twig_SimpleFunction) {
    return $function
      ->getNodeClass();
  }
  return $function instanceof Twig_Function_Node ? $function
    ->getClass() : 'Twig_Node_Expression_Function';
}