Example #1
0
 public function __construct(Twig_NodeInterface $node, $name, Twig_NodeInterface $arguments = null, $lineno)
 {
     parent::__construct($node, $name, $arguments, $lineno);
     if ($node instanceof Twig_Node_Expression_Name) {
         $node->setAttribute('is_defined_test', true);
     } elseif ($node instanceof Twig_Node_Expression_GetAttr) {
         $node->setAttribute('is_defined_test', true);
         $this->changeIgnoreStrictCheck($node);
     } else {
         throw new Twig_Error_Syntax('The "defined" test only works with simple variables', $this->getLine());
     }
 }
Example #2
0
 public function __construct(Twig_Node $node, $name, Twig_Node $arguments = null, $lineno)
 {
     if ($node instanceof Twig_Node_Expression_Name) {
         $node->setAttribute('is_defined_test', true);
     } elseif ($node instanceof Twig_Node_Expression_GetAttr) {
         $node->setAttribute('is_defined_test', true);
         $this->changeIgnoreStrictCheck($node);
     } elseif ($node instanceof Twig_Node_Expression_Constant || $node instanceof Twig_Node_Expression_Array || $node instanceof Twig_Node_Expression_GetProperty || $node instanceof Twig_Node_Expression_MethodCall) {
         $node = new Twig_Node_Expression_Constant(true, $node->getLine());
     } else {
         throw new Twig_Error_Syntax('The "defined" test only works with simple variables.', $this->getLine());
     }
     parent::__construct($node, $name, $arguments, $lineno);
 }
Example #3
0
 public function __construct(Twig_NodeInterface $node, $name, Twig_NodeInterface $arguments = null, $lineno)
 {
     if ($node instanceof Twig_Node_Expression_Name) {
         $node->setAttribute('is_defined_test', true);
     } elseif ($node instanceof Twig_Node_Expression_GetAttr) {
         $node->setAttribute('is_defined_test', true);
         $this->changeIgnoreStrictCheck($node);
     } elseif ($node instanceof Twig_Node_Expression_BlockReference) {
         $node->setAttribute('is_defined_test', true);
     } elseif ($node instanceof Twig_Node_Expression_Function && 'constant' === $node->getAttribute('name')) {
         $node->setAttribute('is_defined_test', true);
     } elseif ($node instanceof Twig_Node_Expression_Constant || $node instanceof Twig_Node_Expression_Array) {
         $node = new Twig_Node_Expression_Constant(true, $node->getTemplateLine());
     } else {
         throw new Twig_Error_Syntax('The "defined" test only works with simple variables.', $this->getTemplateLine());
     }
     parent::__construct($node, $name, $arguments, $lineno);
 }