class ExpressionFunction
Represents a function that can be used in an expression.
A function is defined by two PHP callables. The callables are used by the language to compile and/or evaluate the function.
The "compiler" function is used at compilation time and must return a PHP representation of the function call (it receives the function arguments as arguments).
The "evaluator" function is used for expression evaluation and must return the value of the function call based on the values defined for the expression (it receives the values as a first argument and the function arguments as remaining arguments).
__construct(string $name, callable $compiler, callable $evaluator) | ||
getName() | ||
getCompiler() | ||
getEvaluator() | ||
static ExpressionFunction | fromPhp(string $phpFunctionName, string|null $expressionFunctionName = null) Creates an ExpressionFunction from a PHP function name. |
string | $name | The function name |
callable | $compiler | A callable able to compile the function |
callable | $evaluator | A callable able to evaluate the function |
Creates an ExpressionFunction from a PHP function name.
string | $phpFunctionName | The PHP function name |
string|null | $expressionFunctionName | The expression function name (default: same than the PHP function name) |
ExpressionFunction |
InvalidArgumentException | if given PHP function name does not exist |
InvalidArgumentException | if given PHP function name is in namespace and expression function name is not defined |
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/ExpressionLanguage/ExpressionFunction.html