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
46
47
48
49
50
51
52
|
<?php
/* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */
namespace Symfony\Component\ExpressionLanguage\Node;
use Symfony\Component\ExpressionLanguage\Compiler;
/** * @author Fabien Potencier <fabien@symfony.com> * * @internal */ class FunctionNode extends Node { public function __construct($name, Node $arguments) { parent::__construct( array('arguments' => $arguments), array('name' => $name) ); }
public function compile(Compiler $compiler) { $arguments = array(); foreach ($this->nodes['arguments']->nodes as $node) { $arguments[] = $compiler->subcompile($node); }
$function = $compiler->getFunction($this->attributes['name']);
$compiler->raw(\call_user_func_array($function['compiler'], $arguments)); }
public function evaluate($functions, $values) { $arguments = array($values); foreach ($this->nodes['arguments']->nodes as $node) { $arguments[] = $node->evaluate($functions, $values); }
return \call_user_func_array($functions[$this->attributes['name']]['evaluator'], $arguments); } }
|