PHP code example of uuf6429 / expression-language-arrowfunc
1. Go to this page and download the library: Download uuf6429/expression-language-arrowfunc library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
uuf6429 / expression-language-arrowfunc example snippets
use uuf6429\ExpressionLanguage\ExpressionLanguageWithArrowFunctions;
$el = new ExpressionLanguageWithArrowFunctions();
$phpCode = $el->compile('(val) -> { val * 2 }', []);
assert($phpCode === 'function ($val) { return ($val * 2); }');
use Symfony\Component\ExpressionLanguage\ExpressionLanguage as SymfonyExpressionLanguage;
use Symfony\Component\ExpressionLanguage\ParsedExpression as SymfonyParsedExpression;
use uuf6429\ExpressionLanguage\ArrowFunctionTrait;
class MyCustomExpressionLanguage
{
use ArrowFunctionTrait;
public function evaluate($expression, $values = [])
{
return $this->evaluateWithArrowFunctions($expression, $values);
}
public function compile($expression, $names = [])
{
return $this->compileWithArrowFunctions($expression, $names);
}
protected function compileWithoutArrowFunctions($expression, array $names = []): string
{
// TODO Implement method
}
protected function evaluateWithoutArrowFunctions($expression, array $values = [])
{
// TODO Implement method
}
protected function parseWithoutArrowFunctions($expression, array $names = []): SymfonyParsedExpression
{
// TODO Implement method
}
protected function lintWithoutArrowFunctions($expression, array $names = []): void
{
// TODO Implement method
}
}