4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\ExpressionLanguage\Node;
14 use Symfony\Component\ExpressionLanguage\Compiler;
17 * @author Fabien Potencier <fabien@symfony.com>
21 class FunctionNode extends Node
23 public function __construct($name, Node $arguments)
26 array('arguments' => $arguments),
27 array('name' => $name)
31 public function compile(Compiler $compiler)
34 foreach ($this->nodes['arguments']->nodes as $node) {
35 $arguments[] = $compiler->subcompile($node);
38 $function = $compiler->getFunction($this->attributes['name']);
40 $compiler->raw(call_user_func_array($function['compiler'], $arguments));
43 public function evaluate($functions, $values)
45 $arguments = array($values);
46 foreach ($this->nodes['arguments']->nodes as $node) {
47 $arguments[] = $node->evaluate($functions, $values);
50 return call_user_func_array($functions[$this->attributes['name']]['evaluator'], $arguments);