Dotclear


Ignore:
Timestamp:
02/15/13 08:35:19 (13 years ago)
Author:
Dsls <dsls@…>
Branch:
twig
Children:
1106:a4487f3ca4b4, 1147:2e5cb79e4782
Message:

Twig 1.12.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inc/libs/twig/Node/Expression/Function.php

    r991 r1101  
    99 * file that was distributed with this source code. 
    1010 */ 
    11 class Twig_Node_Expression_Function extends Twig_Node_Expression 
     11class Twig_Node_Expression_Function extends Twig_Node_Expression_Call 
    1212{ 
    1313    public function __construct($name, Twig_NodeInterface $arguments, $lineno) 
     
    1919    { 
    2020        $name = $this->getAttribute('name'); 
     21        $function = $compiler->getEnvironment()->getFunction($name); 
    2122 
    22         if (false === $function = $compiler->getEnvironment()->getFunction($name)) { 
    23             $message = sprintf('The function "%s" does not exist', $name); 
    24             if ($alternatives = $compiler->getEnvironment()->computeAlternatives($name, array_keys($compiler->getEnvironment()->getFunctions()))) { 
    25                 $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives)); 
    26             } 
    27  
    28             throw new Twig_Error_Syntax($message, $this->getLine(), $compiler->getFilename()); 
     23        $this->setAttribute('name', $name); 
     24        $this->setAttribute('type', 'function'); 
     25        $this->setAttribute('thing', $function); 
     26        $this->setAttribute('needs_environment', $function->needsEnvironment()); 
     27        $this->setAttribute('needs_context', $function->needsContext()); 
     28        $this->setAttribute('arguments', $function->getArguments()); 
     29        if ($function instanceof Twig_FunctionCallableInterface || $function instanceof Twig_SimpleFunction) { 
     30            $this->setAttribute('callable', $function->getCallable()); 
    2931        } 
    3032 
    31         $compiler->raw($function->compile().'('); 
    32  
    33         $first = true; 
    34  
    35         if ($function->needsEnvironment()) { 
    36             $compiler->raw('$this->env'); 
    37             $first = false; 
    38         } 
    39  
    40         if ($function->needsContext()) { 
    41             if (!$first) { 
    42                 $compiler->raw(', '); 
    43             } 
    44             $compiler->raw('$context'); 
    45             $first = false; 
    46         } 
    47  
    48         foreach ($function->getArguments() as $argument) { 
    49             if (!$first) { 
    50                 $compiler->raw(', '); 
    51             } 
    52             $compiler->string($argument); 
    53             $first = false; 
    54         } 
    55  
    56         foreach ($this->getNode('arguments') as $node) { 
    57             if (!$first) { 
    58                 $compiler->raw(', '); 
    59             } 
    60             $compiler->subcompile($node); 
    61             $first = false; 
    62         } 
    63  
    64         $compiler->raw(')'); 
     33        $this->compileCallable($compiler); 
    6534    } 
    6635} 
Note: See TracChangeset for help on using the changeset viewer.

Sites map