Project

General

Profile

1
<?php
2

    
3
/*
4
 * This file is part of Twig.
5
 *
6
 * (c) 2012 Fabien Potencier
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
class Twig_Node_Expression_MethodCall extends Twig_Node_Expression
12
{
13
    public function __construct(Twig_Node_Expression $node, $method, Twig_Node_Expression_Array $arguments, $lineno)
14
    {
15
        parent::__construct(array('node' => $node, 'arguments' => $arguments), array('method' => $method, 'safe' => false), $lineno);
16
    }
17

    
18
    public function compile(Twig_Compiler $compiler)
19
    {
20
        $compiler
21
            ->subcompile($this->getNode('node'))
22
            ->raw('->')
23
            ->raw($this->getAttribute('method'))
24
            ->raw('(')
25
        ;
26
        $first = true;
27
        foreach ($this->getNode('arguments')->getKeyValuePairs() as $pair) {
28
            if (!$first) {
29
                $compiler->raw(', ');
30
            }
31
            $first = false;
32

    
33
            $compiler->subcompile($pair['value']);
34
        }
35
        $compiler->raw(')');
36
    }
37
}
(11-11/16)