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;
15 * Represents a function that can be used in an expression.
17 * A function is defined by two PHP callables. The callables are used
18 * by the language to compile and/or evaluate the function.
20 * The "compiler" function is used at compilation time and must return a
21 * PHP representation of the function call (it receives the function
22 * arguments as arguments).
24 * The "evaluator" function is used for expression evaluation and must return
25 * the value of the function call based on the values defined for the
26 * expression (it receives the values as a first argument and the function
27 * arguments as remaining arguments).
29 * @author Fabien Potencier <fabien@symfony.com>
31 class ExpressionFunction
40 * @param string $name The function name
41 * @param callable $compiler A callable able to compile the function
42 * @param callable $evaluator A callable able to evaluate the function
44 public function __construct($name, $compiler, $evaluator)
47 $this->compiler = $compiler;
48 $this->evaluator = $evaluator;
51 public function getName()
56 public function getCompiler()
58 return $this->compiler;
61 public function getEvaluator()
63 return $this->evaluator;