Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Expression.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Symfony\Component\ExpressionLanguage;
namespace Hellocasa\Component\ExpressionLanguage;

/**
* Represents an expression.
Expand Down
2 changes: 1 addition & 1 deletion ExpressionFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion ExpressionFunctionProviderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Symfony\Component\ExpressionLanguage;
namespace Hellocasa\Component\ExpressionLanguage;

/**
* @author Fabien Potencier <[email protected]>
Expand Down
6 changes: 3 additions & 3 deletions ExpressionLanguage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 15 additions & 0 deletions ExpressionLanguageBundle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Hellocasa\Component\ExpressionLanguage;

use Symfony\Component\HttpKernel\Bundle\Bundle;

/**
* Class ExpressionLanguageBundle.
*
* @package ExpressionLanguageBundle
* @author Krome162504
*/
class ExpressionLanguageBundle extends Bundle
{
}
2 changes: 1 addition & 1 deletion Lexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Symfony\Component\ExpressionLanguage;
namespace Hellocasa\Component\ExpressionLanguage;

/**
* Lexes an expression.
Expand Down
4 changes: 2 additions & 2 deletions Node/ArgumentsNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
Expand Down
4 changes: 2 additions & 2 deletions Node/ArrayNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
Expand Down
4 changes: 2 additions & 2 deletions Node/BinaryNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
Expand Down
4 changes: 2 additions & 2 deletions Node/ConditionalNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
Expand Down
4 changes: 2 additions & 2 deletions Node/ConstantNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
Expand Down
4 changes: 2 additions & 2 deletions Node/FunctionNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
Expand Down
6 changes: 3 additions & 3 deletions Node/GetAttrNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
Expand Down
4 changes: 2 additions & 2 deletions Node/NameNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
Expand Down
4 changes: 2 additions & 2 deletions Node/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions Node/UnaryNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
Expand Down
4 changes: 2 additions & 2 deletions ParsedExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Symfony\Component\ExpressionLanguage;
namespace Hellocasa\Component\ExpressionLanguage;

/**
* Parsers a token stream.
Expand Down
4 changes: 2 additions & 2 deletions ParserCache/ArrayParserCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
Expand Down
4 changes: 2 additions & 2 deletions ParserCache/ParserCacheAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
Expand Down
4 changes: 2 additions & 2 deletions ParserCache/ParserCacheInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
Expand Down
58 changes: 49 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -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": "[email protected]: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)
2 changes: 1 addition & 1 deletion SerializedParsedExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion SyntaxError.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Symfony\Component\ExpressionLanguage;
namespace Hellocasa\Component\ExpressionLanguage;

class SyntaxError extends \LogicException
{
Expand Down
2 changes: 1 addition & 1 deletion Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Symfony\Component\ExpressionLanguage;
namespace Hellocasa\Component\ExpressionLanguage;

/**
* Represents a Token.
Expand Down
2 changes: 1 addition & 1 deletion TokenStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Symfony\Component\ExpressionLanguage;
namespace Hellocasa\Component\ExpressionLanguage;

/**
* Represents a token stream.
Expand Down
Loading