composer package updates
[openemr.git] / vendor / twig / twig / lib / Twig / Node / Expression / GetAttr.php
blobb7823accb935bddd7028aa01094c383acc231792
1 <?php
3 /*
4 * This file is part of Twig.
6 * (c) Fabien Potencier
7 * (c) Armin Ronacher
9 * For the full copyright and license information, please view the LICENSE
10 * file that was distributed with this source code.
12 class Twig_Node_Expression_GetAttr extends Twig_Node_Expression
14 public function __construct(Twig_Node_Expression $node, Twig_Node_Expression $attribute, Twig_Node_Expression $arguments = null, $type, $lineno)
16 $nodes = array('node' => $node, 'attribute' => $attribute);
17 if (null !== $arguments) {
18 $nodes['arguments'] = $arguments;
21 parent::__construct($nodes, array('type' => $type, 'is_defined_test' => false, 'ignore_strict_check' => false, 'disable_c_ext' => false), $lineno);
24 public function compile(Twig_Compiler $compiler)
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);
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(');
36 if ($this->getAttribute('ignore_strict_check')) {
37 $this->getNode('node')->setAttribute('ignore_strict_check', true);
40 $compiler->subcompile($this->getNode('node'));
42 $compiler->raw(', ')->subcompile($this->getNode('attribute'));
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');
50 if ($needFirst) {
51 if ($this->hasNode('arguments')) {
52 $compiler->raw(', ')->subcompile($this->getNode('arguments'));
53 } else {
54 $compiler->raw(', array()');
58 if ($needSecond) {
59 $compiler->raw(', ')->repr($this->getAttribute('type'));
62 if ($needThird) {
63 $compiler->raw(', ')->repr($this->getAttribute('is_defined_test'));
66 if ($needFourth) {
67 $compiler->raw(', ')->repr($this->getAttribute('ignore_strict_check'));
70 $compiler->raw(')');
74 class_alias('Twig_Node_Expression_GetAttr', 'Twig\Node\Expression\GetAttrExpression', false);