forked from twigphp/Twig
/
GetAttr.php
45 lines (40 loc) · 1.19 KB
/
GetAttr.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
/*
* This file is part of Twig.
*
* (c) 2009 Fabien Potencier
* (c) 2009 Armin Ronacher
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
class Twig_Node_Expression_GetAttr extends Twig_Node_Expression
{
const TYPE_ANY = 'any';
const TYPE_ARRAY = 'array';
const TYPE_METHOD = 'method';
public function __construct(Twig_Node_Expression $node, Twig_Node_Expression $attribute, Twig_NodeInterface $arguments, $lineno, $type = self::TYPE_ANY)
{
parent::__construct(array('node' => $node, 'attribute' => $attribute, 'arguments' => $arguments), array('type' => $type), $lineno);
}
public function compile($compiler)
{
$compiler
->raw('$this->getAttribute(')
->subcompile($this->node)
->raw(', ')
->subcompile($this->attribute)
->raw(', array(')
;
foreach ($this->arguments as $node) {
$compiler
->subcompile($node)
->raw(', ')
;
}
$compiler
->raw('), ')
->repr($this['type'])
->raw(')');
}
}