Example #1
0
 /**
  * @covers Twig_Node_Macro::__construct
  */
 public function testConstructor()
 {
     $body = new Twig_Node_Text('foo', 1);
     $arguments = new Twig_Node(array(new Twig_Node_Expression_Name('foo', 1)), array(), 1);
     $node = new Twig_Node_Macro('foo', $body, $arguments, 1);
     $this->assertEquals($body, $node->getNode('body'));
     $this->assertEquals($arguments, $node->getNode('arguments'));
     $this->assertEquals('foo', $node->getAttribute('name'));
 }
Example #2
0
 public function setMacro($name, Twig_Node_Macro $node)
 {
     if ($this->isReservedMacroName($name)) {
         throw new Twig_Error_Syntax(sprintf('"%s" cannot be used as a macro name as it is a reserved keyword', $name), $node->getLine(), $this->getFilename());
     }
     $this->macros[$name] = $node;
 }
Example #3
0
 public function setMacro($name, Twig_Node_Macro $node)
 {
     if (null === $this->reservedMacroNames) {
         $this->reservedMacroNames = array();
         $r = new ReflectionClass($this->env->getBaseTemplateClass());
         foreach ($r->getMethods() as $method) {
             $this->reservedMacroNames[] = $method->getName();
         }
     }
     if (in_array($name, $this->reservedMacroNames)) {
         throw new Twig_Error_Syntax(sprintf('"%s" cannot be used as a macro name as it is a reserved keyword', $name), $node->getLine());
     }
     $this->macros[$name] = $node;
 }
 public function setMacro($name, Twig_Node_Macro $node)
 {
     if ($this->isReservedMacroName($name)) {
         throw new Twig_Error_Syntax(sprintf('"%s" cannot be used as a macro name as it is a reserved keyword.', $name), $node->getTemplateLine(), $this->stream->getSourceContext()->getName());
     }
     $this->macros[$name] = $node;
 }