ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
GetAttr.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of Twig.
5  *
6  * (c) Fabien Potencier
7  * (c) Armin Ronacher
8  *
9  * For the full copyright and license information, please view the LICENSE
10  * file that was distributed with this source code.
11  */
13 {
14  public function __construct(Twig_Node_Expression $node, Twig_Node_Expression $attribute, Twig_Node_Expression $arguments = null, $type, $lineno)
15  {
16  $nodes = array('node' => $node, 'attribute' => $attribute);
17  if (null !== $arguments) {
18  $nodes['arguments'] = $arguments;
19  }
20 
21  parent::__construct($nodes, array('type' => $type, 'is_defined_test' => false, 'ignore_strict_check' => false, 'disable_c_ext' => false), $lineno);
22  }
23 
24  public function compile(Twig_Compiler $compiler)
25  {
26  if ($this->getAttribute('disable_c_ext')) {
27  @trigger_error(sprintf('Using the "disable_c_ext" attribute on %s is deprecated since version 1.30 and will be removed in 2.0.', __CLASS__), E_USER_DEPRECATED);
28  }
29 
30  if (function_exists('twig_template_get_attributes') && !$this->getAttribute('disable_c_ext')) {
31  $compiler->raw('twig_template_get_attributes($this, ');
32  } else {
33  $compiler->raw('$this->getAttribute(');
34  }
35 
36  if ($this->getAttribute('ignore_strict_check')) {
37  $this->getNode('node')->setAttribute('ignore_strict_check', true);
38  }
39 
40  $compiler->subcompile($this->getNode('node'));
41 
42  $compiler->raw(', ')->subcompile($this->getNode('attribute'));
43 
44  // only generate optional arguments when needed (to make generated code more readable)
45  $needFourth = $this->getAttribute('ignore_strict_check');
46  $needThird = $needFourth || $this->getAttribute('is_defined_test');
47  $needSecond = $needThird || Twig_Template::ANY_CALL !== $this->getAttribute('type');
48  $needFirst = $needSecond || $this->hasNode('arguments');
49 
50  if ($needFirst) {
51  if ($this->hasNode('arguments')) {
52  $compiler->raw(', ')->subcompile($this->getNode('arguments'));
53  } else {
54  $compiler->raw(', array()');
55  }
56  }
57 
58  if ($needSecond) {
59  $compiler->raw(', ')->repr($this->getAttribute('type'));
60  }
61 
62  if ($needThird) {
63  $compiler->raw(', ')->repr($this->getAttribute('is_defined_test'));
64  }
65 
66  if ($needFourth) {
67  $compiler->raw(', ')->repr($this->getAttribute('ignore_strict_check'));
68  }
69 
70  $compiler->raw(')');
71  }
72 }
73 
74 class_alias('Twig_Node_Expression_GetAttr', 'Twig\Node\Expression\GetAttrExpression', false);
$lineno
Definition: Node.php:22
raw($string)
Adds a raw string to the compiled code.
Definition: Compiler.php:112
compile(Twig_Compiler $compiler)
Compiles the node to PHP.
Definition: GetAttr.php:24
subcompile(Twig_NodeInterface $node, $raw=true)
Definition: Compiler.php:94
$type
Abstract class for all nodes that represents an expression.
Definition: Expression.php:18
$nodes
Definition: Node.php:20
__construct(Twig_Node_Expression $node, Twig_Node_Expression $attribute, Twig_Node_Expression $arguments=null, $type, $lineno)
Definition: GetAttr.php:14
getAttribute($name)
Definition: Node.php:152
hasNode($name)
Definition: Node.php:178
Create styles array
The data for the language used.
getNode($name)
Definition: Node.php:186