diff --git a/Compiler.php b/Compiler.php index 66d1060..e497b14 100644 --- a/Compiler.php +++ b/Compiler.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ExpressionLanguage; +namespace Hellocasa\Component\ExpressionLanguage; /** * Compiles a node to PHP code. diff --git a/Expression.php b/Expression.php index ac656cc..978aa8d 100644 --- a/Expression.php +++ b/Expression.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ExpressionLanguage; +namespace Hellocasa\Component\ExpressionLanguage; /** * Represents an expression. diff --git a/ExpressionFunction.php b/ExpressionFunction.php index ad775db..a3b526a 100644 --- a/ExpressionFunction.php +++ b/ExpressionFunction.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ExpressionLanguage; +namespace Hellocasa\Component\ExpressionLanguage; /** * Represents a function that can be used in an expression. diff --git a/ExpressionFunctionProviderInterface.php b/ExpressionFunctionProviderInterface.php index 414b013..623f644 100644 --- a/ExpressionFunctionProviderInterface.php +++ b/ExpressionFunctionProviderInterface.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ExpressionLanguage; +namespace Hellocasa\Component\ExpressionLanguage; /** * @author Fabien Potencier diff --git a/ExpressionLanguage.php b/ExpressionLanguage.php index a9cfc4c..a708756 100644 --- a/ExpressionLanguage.php +++ b/ExpressionLanguage.php @@ -9,12 +9,12 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ExpressionLanguage; +namespace Hellocasa\Component\ExpressionLanguage; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; -use Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheAdapter; -use Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface; +use Hellocasa\Component\ExpressionLanguage\ParserCache\ParserCacheAdapter; +use Hellocasa\Component\ExpressionLanguage\ParserCache\ParserCacheInterface; /** * Allows to compile and evaluate expressions written in your own DSL. diff --git a/ExpressionLanguageBundle.php b/ExpressionLanguageBundle.php new file mode 100644 index 0000000..cf7cfc3 --- /dev/null +++ b/ExpressionLanguageBundle.php @@ -0,0 +1,15 @@ + diff --git a/Node/ArrayNode.php b/Node/ArrayNode.php index e1a2f2e..5aa2955 100644 --- a/Node/ArrayNode.php +++ b/Node/ArrayNode.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ExpressionLanguage\Node; +namespace Hellocasa\Component\ExpressionLanguage\Node; -use Symfony\Component\ExpressionLanguage\Compiler; +use Hellocasa\Component\ExpressionLanguage\Compiler; /** * @author Fabien Potencier diff --git a/Node/BinaryNode.php b/Node/BinaryNode.php index 33b4c8f..cef3f70 100644 --- a/Node/BinaryNode.php +++ b/Node/BinaryNode.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ExpressionLanguage\Node; +namespace Hellocasa\Component\ExpressionLanguage\Node; -use Symfony\Component\ExpressionLanguage\Compiler; +use Hellocasa\Component\ExpressionLanguage\Compiler; /** * @author Fabien Potencier diff --git a/Node/ConditionalNode.php b/Node/ConditionalNode.php index 9db0f93..cc2558b 100644 --- a/Node/ConditionalNode.php +++ b/Node/ConditionalNode.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ExpressionLanguage\Node; +namespace Hellocasa\Component\ExpressionLanguage\Node; -use Symfony\Component\ExpressionLanguage\Compiler; +use Hellocasa\Component\ExpressionLanguage\Compiler; /** * @author Fabien Potencier diff --git a/Node/ConstantNode.php b/Node/ConstantNode.php index 733d481..47635be 100644 --- a/Node/ConstantNode.php +++ b/Node/ConstantNode.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ExpressionLanguage\Node; +namespace Hellocasa\Component\ExpressionLanguage\Node; -use Symfony\Component\ExpressionLanguage\Compiler; +use Hellocasa\Component\ExpressionLanguage\Compiler; /** * @author Fabien Potencier diff --git a/Node/FunctionNode.php b/Node/FunctionNode.php index 13928c8..10fdd2f 100644 --- a/Node/FunctionNode.php +++ b/Node/FunctionNode.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ExpressionLanguage\Node; +namespace Hellocasa\Component\ExpressionLanguage\Node; -use Symfony\Component\ExpressionLanguage\Compiler; +use Hellocasa\Component\ExpressionLanguage\Compiler; /** * @author Fabien Potencier diff --git a/Node/GetAttrNode.php b/Node/GetAttrNode.php index 0ff4ab2..bf353bd 100644 --- a/Node/GetAttrNode.php +++ b/Node/GetAttrNode.php @@ -9,10 +9,10 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ExpressionLanguage\Node; +namespace Hellocasa\Component\ExpressionLanguage\Node; -use Symfony\Component\ExpressionLanguage\Compiler; -use Symfony\Component\ExpressionLanguage\SyntaxError; +use Hellocasa\Component\ExpressionLanguage\Compiler; +use Hellocasa\Component\ExpressionLanguage\SyntaxError; /** * @author Fabien Potencier diff --git a/Node/NameNode.php b/Node/NameNode.php index 9e1462f..eaa54e8 100644 --- a/Node/NameNode.php +++ b/Node/NameNode.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ExpressionLanguage\Node; +namespace Hellocasa\Component\ExpressionLanguage\Node; -use Symfony\Component\ExpressionLanguage\Compiler; +use Hellocasa\Component\ExpressionLanguage\Compiler; /** * @author Fabien Potencier diff --git a/Node/Node.php b/Node/Node.php index 1db4e85..97df5a9 100644 --- a/Node/Node.php +++ b/Node/Node.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ExpressionLanguage\Node; +namespace Hellocasa\Component\ExpressionLanguage\Node; -use Symfony\Component\ExpressionLanguage\Compiler; +use Hellocasa\Component\ExpressionLanguage\Compiler; /** * Represents a node in the AST. diff --git a/Node/UnaryNode.php b/Node/UnaryNode.php index 5831032..0230e07 100644 --- a/Node/UnaryNode.php +++ b/Node/UnaryNode.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ExpressionLanguage\Node; +namespace Hellocasa\Component\ExpressionLanguage\Node; -use Symfony\Component\ExpressionLanguage\Compiler; +use Hellocasa\Component\ExpressionLanguage\Compiler; /** * @author Fabien Potencier diff --git a/ParsedExpression.php b/ParsedExpression.php index a5603fc..5c3cc27 100644 --- a/ParsedExpression.php +++ b/ParsedExpression.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ExpressionLanguage; +namespace Hellocasa\Component\ExpressionLanguage; -use Symfony\Component\ExpressionLanguage\Node\Node; +use Hellocasa\Component\ExpressionLanguage\Node\Node; /** * Represents an already parsed expression. diff --git a/Parser.php b/Parser.php index 4b1ce8e..164a452 100644 --- a/Parser.php +++ b/Parser.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ExpressionLanguage; +namespace Hellocasa\Component\ExpressionLanguage; /** * Parsers a token stream. diff --git a/ParserCache/ArrayParserCache.php b/ParserCache/ArrayParserCache.php index 1249625..3064eb1 100644 --- a/ParserCache/ArrayParserCache.php +++ b/ParserCache/ArrayParserCache.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ExpressionLanguage\ParserCache; +namespace Hellocasa\Component\ExpressionLanguage\ParserCache; @trigger_error('The '.__NAMESPACE__.'\ArrayParserCache class is deprecated since Symfony 3.2 and will be removed in 4.0. Use the Symfony\Component\Cache\Adapter\ArrayAdapter class instead.', E_USER_DEPRECATED); -use Symfony\Component\ExpressionLanguage\ParsedExpression; +use Hellocasa\Component\ExpressionLanguage\ParsedExpression; /** * @author Adrien Brault diff --git a/ParserCache/ParserCacheAdapter.php b/ParserCache/ParserCacheAdapter.php index a3e227d..8e451f3 100644 --- a/ParserCache/ParserCacheAdapter.php +++ b/ParserCache/ParserCacheAdapter.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ExpressionLanguage\ParserCache; +namespace Hellocasa\Component\ExpressionLanguage\ParserCache; use Psr\Cache\CacheItemInterface; use Psr\Cache\CacheItemPoolInterface; -use Symfony\Component\Cache\CacheItem; +use Hellocasa\Component\Cache\CacheItem; /** * @author Alexandre GESLIN diff --git a/ParserCache/ParserCacheInterface.php b/ParserCache/ParserCacheInterface.php index ed66b21..a0239e0 100644 --- a/ParserCache/ParserCacheInterface.php +++ b/ParserCache/ParserCacheInterface.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ExpressionLanguage\ParserCache; +namespace Hellocasa\Component\ExpressionLanguage\ParserCache; @trigger_error('The '.__NAMESPACE__.'\ParserCacheInterface interface is deprecated since Symfony 3.2 and will be removed in 4.0. Use Psr\Cache\CacheItemPoolInterface instead.', E_USER_DEPRECATED); -use Symfony\Component\ExpressionLanguage\ParsedExpression; +use Hellocasa\Component\ExpressionLanguage\ParsedExpression; /** * @author Adrien Brault diff --git a/README.md b/README.md index 08b310d..f1afc3d 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,55 @@ -ExpressionLanguage Component -============================ +### How To Update and modify + +In your composer.json, add the repo in your `repositories` key: + +https://getcomposer.org/doc/05-repositories.md#vcs + +``` + "repositories": [ + { + "type": "vcs", + "url": "git@github.com:Hellocasa/expression-language.git" + } + ], +``` + +``` +composer require hellocasa/expression-language:dev-hellocasa +``` + +Add it in AppKernel + +``` + ... + new Hellocasa\Component\ExpressionLanguage\ExpressionLanguageBundle(), + ... +``` + +Work like Symfony ExpressionLanguage but it throw an SyntaxError when variables into the expression is wrong https://symfony.com/doc/current/components/expression_language.html#passing-in-variables + +### Exemple: + +``` +$expressionLanguage->evaluate( + 'quantities[1]+quantities[3]', + array( + 'quantities' => [1 => 30, 2 => 50], + ) +); +``` + +Here quantity 3 not exist and throw ContextErrorException: Undefined offset, with this bundle now it throw an SyntaxError + +# ExpressionLanguage Component The ExpressionLanguage component provides an engine that can compile and evaluate expressions. An expression is a one-liner that returns a value (mostly, but not limited to, Booleans). -Resources ---------- +## Resources - * [Documentation](https://symfony.com/doc/current/components/expression_language/introduction.html) - * [Contributing](https://symfony.com/doc/current/contributing/index.html) - * [Report issues](https://github.com/symfony/symfony/issues) and - [send Pull Requests](https://github.com/symfony/symfony/pulls) - in the [main Symfony repository](https://github.com/symfony/symfony) +* [Documentation](https://symfony.com/doc/current/components/expression_language/introduction.html) +* [Contributing](https://symfony.com/doc/current/contributing/index.html) +* [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/SerializedParsedExpression.php b/SerializedParsedExpression.php index dd763f7..a449d35 100644 --- a/SerializedParsedExpression.php +++ b/SerializedParsedExpression.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ExpressionLanguage; +namespace Hellocasa\Component\ExpressionLanguage; /** * Represents an already parsed expression. diff --git a/SyntaxError.php b/SyntaxError.php index 12348e6..2a22bda 100644 --- a/SyntaxError.php +++ b/SyntaxError.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ExpressionLanguage; +namespace Hellocasa\Component\ExpressionLanguage; class SyntaxError extends \LogicException { diff --git a/Token.php b/Token.php index 4517335..fc316b0 100644 --- a/Token.php +++ b/Token.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ExpressionLanguage; +namespace Hellocasa\Component\ExpressionLanguage; /** * Represents a Token. diff --git a/TokenStream.php b/TokenStream.php index 9096b18..170b450 100644 --- a/TokenStream.php +++ b/TokenStream.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ExpressionLanguage; +namespace Hellocasa\Component\ExpressionLanguage; /** * Represents a token stream. diff --git a/composer.json b/composer.json index 5f662ff..f3838d2 100644 --- a/composer.json +++ b/composer.json @@ -1,34 +1,32 @@ { - "name": "symfony/expression-language", - "type": "library", - "description": "Symfony ExpressionLanguage Component", - "keywords": [], - "homepage": "https://symfony.com", - "license": "MIT", - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/cache": "~3.1|~4.0" + "name": "hellocasa/expression-language", + "type": "library", + "description": "Symfony ExpressionLanguage Component", + "keywords": [], + "homepage": "https://symfony.com", + "license": "MIT", + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" }, - "autoload": { - "psr-4": { "Symfony\\Component\\ExpressionLanguage\\": "" }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "minimum-stability": "dev", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "require": { + "php": "^5.5.9|>=7.0.8", + "symfony/cache": "~3.1|~4.0" + }, + "autoload": { + "psr-4": { "Hellocasa\\Component\\ExpressionLanguage\\": "" }, + "exclude-from-classmap": ["/Tests/"] + }, + "minimum-stability": "dev", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" } + } }