public function Twig_Node_Expression_Test_Defined::__construct in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/twig/twig/lib/Twig/Node/Expression/Test/Defined.php \Twig_Node_Expression_Test_Defined::__construct()
Constructor.
The nodes are automatically made available as properties ($this->node). The attributes are automatically made available as array items ($this['name']).
Parameters
array $nodes An array of named nodes:
array $attributes An array of attributes (should not be nodes):
int $lineno The line number:
string $tag The tag name associated with the Node:
Overrides Twig_Node_Expression_Test::__construct
File
- vendor/
twig/ twig/ lib/ Twig/ Node/ Expression/ Test/ Defined.php, line 26
Class
- Twig_Node_Expression_Test_Defined
- Checks if a variable is defined in the current context.
Code
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());
}
}