Skip to content

Commit

Permalink
Several fixes + integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
uuf6429 committed Oct 30, 2016
1 parent 8cc02b9 commit 5173bcd
Show file tree
Hide file tree
Showing 7 changed files with 803 additions and 22 deletions.
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions src/ExpressionLanguage/ExpressionLanguage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace uuf6429\ExpressionLanguage;

use Symfony\Component\ExpressionLanguage\ExpressionLanguage as SymfonyExpressionLanguage;

class ExpressionLanguage extends SymfonyExpressionLanguage
{
/** @var Parser */
protected $parser;

/**
* {@inheritdoc}
*/
public function __construct($cache = null, array $providers = array())
{
$this->parser = new Parser(array());

parent::__construct($cache, $providers);

$reflection = new \ReflectionClass(SymfonyExpressionLanguage::class);

$prop = $reflection->getProperty('lexer');
$prop->setAccessible(true);
$prop->setValue($this, new Lexer());
$prop->setAccessible(false);

$prop = $reflection->getProperty('parser');
$prop->setAccessible(true);
$prop->setValue($this, $this->parser);
$prop->setAccessible(false);
}

/**
* Hack to keep functions in parser up to date.
*
* {@inheritdoc}
*/
public function register($name, callable $compiler, callable $evaluator)
{
parent::register($name, $compiler, $evaluator);
$this->parser->setFunctions($this->functions);
}
}
2 changes: 1 addition & 1 deletion src/ExpressionLanguage/Lexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Symfony\Component\ExpressionLanguage\Token;
use Symfony\Component\ExpressionLanguage\SyntaxError;

class Lexer extends Symfony\Component\ExpressionLanguage\Lexer
class Lexer extends \Symfony\Component\ExpressionLanguage\Lexer
{
/**
* {@inheritdoc}
Expand Down
Loading

0 comments on commit 5173bcd

Please sign in to comment.