2017 © Pedro Peláez
 

library expression-language

Symfony ExpressionLanguage Component Fork

image

xavren/expression-language

Symfony ExpressionLanguage Component Fork

  • Thursday, October 15, 2015
  • by xavren
  • Repository
  • 0 Watchers
  • 0 Stars
  • 212 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

ExpressionLanguage Component

The ExpressionLanguage component provides an engine that can compile and evaluate expressions:, (*1)

use Hydra\Component\ExpressionLanguage\ExpressionLanguage;

$language = new ExpressionLanguage();

echo $language->evaluate('1 + foo', array('foo' => 2));
// would output 3

echo $language->compile('1 + foo', array('foo'));
// would output (1 + $foo)

By default, the engine implements simple math and logic functions, method calls, property accesses, and array accesses., (*2)

You can extend your DSL with functions:, (*3)

$compiler = function ($arg) {
    return sprintf('strtoupper(%s)', $arg);
};
$evaluator = function (array $variables, $value) {
    return strtoupper($value);
};
$language->register('upper', $compiler, $evaluator);

echo $language->evaluate('"foo" ~ upper(foo)', array('foo' => 'bar'));
// would output fooBAR

echo $language->compile('"foo" ~ upper(foo)');
// would output ("foo" . strtoupper($foo))

Resources

You can run the unit tests with the following command:, (*4)

$ composer.phar install --dev
$ phpunit

The Versions

15/10 2015

dev-master

9999999-dev https://symfony.com

Symfony ExpressionLanguage Component Fork

  Sources   Download

MIT

The Requires

  • php >=5.3.9

 

The Development Requires