Dotclear


Ignore:
Timestamp:
02/15/13 08:35:19 (12 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/Test.php

    r991 r1101  
    99 * file that was distributed with this source code. 
    1010 */ 
    11 class Twig_Node_Expression_Test extends Twig_Node_Expression 
     11class Twig_Node_Expression_Test extends Twig_Node_Expression_Call 
    1212{ 
    1313    public function __construct(Twig_NodeInterface $node, $name, Twig_NodeInterface $arguments = null, $lineno) 
     
    1919    { 
    2020        $name = $this->getAttribute('name'); 
    21         $testMap = $compiler->getEnvironment()->getTests(); 
    22         if (!isset($testMap[$name])) { 
    23             $message = sprintf('The test "%s" does not exist', $name); 
    24             if ($alternatives = $compiler->getEnvironment()->computeAlternatives($name, array_keys($compiler->getEnvironment()->getTests()))) { 
    25                 $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives)); 
    26             } 
     21        $test = $compiler->getEnvironment()->getTest($name); 
    2722 
    28             throw new Twig_Error_Syntax($message, $this->getLine(), $compiler->getFilename()); 
     23        $this->setAttribute('name', $name); 
     24        $this->setAttribute('type', 'test'); 
     25        $this->setAttribute('thing', $test); 
     26        if ($test instanceof Twig_TestCallableInterface || $test instanceof Twig_SimpleTest) { 
     27            $this->setAttribute('callable', $test->getCallable()); 
    2928        } 
    3029 
    31         $name = $this->getAttribute('name'); 
    32         $node = $this->getNode('node'); 
    33  
    34         $compiler 
    35             ->raw($testMap[$name]->compile().'(') 
    36             ->subcompile($node) 
    37         ; 
    38  
    39         if (null !== $this->getNode('arguments')) { 
    40             $compiler->raw(', '); 
    41  
    42             $max = count($this->getNode('arguments')) - 1; 
    43             foreach ($this->getNode('arguments') as $i => $arg) { 
    44                 $compiler->subcompile($arg); 
    45  
    46                 if ($i != $max) { 
    47                     $compiler->raw(', '); 
    48                 } 
    49             } 
    50         } 
    51  
    52         $compiler->raw(')'); 
     30        $this->compileCallable($compiler); 
    5331    } 
    5432} 
Note: See TracChangeset for help on using the changeset viewer.

Sites map