[ExpressionLanguage] fixed CS

This commit is contained in:
Fabien Potencier 2013-09-23 12:22:40 +02:00
parent db00c3f510
commit c43c35cd17
4 changed files with 31 additions and 9 deletions

View File

@ -1,5 +1,14 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bridge\Doctrine\Tests\ExpressionLanguage;
use Symfony\Bridge\Doctrine\ExpressionLanguage\DoctrineParserCache;

View File

@ -24,17 +24,16 @@ class ExpressionLanguage
/**
* @var ParserCacheInterface
*/
private $parserCache;
private $cache;
private $lexer;
private $parser;
private $compiler;
protected $functions;
public function __construct(ParserCacheInterface $parserCache = null)
public function __construct(ParserCacheInterface $cache = null)
{
$this->parserCache = $parserCache ?: new ArrayParserCache();
$this->cache = $cache ?: new ArrayParserCache();
$this->functions = array();
$this->registerFunctions();
}
@ -80,11 +79,11 @@ class ExpressionLanguage
$key = $expression.'//'.implode('-', $names);
if (null === $parsedExpression = $this->parserCache->fetch($key)) {
if (null === $parsedExpression = $this->cache->fetch($key)) {
$nodes = $this->getParser()->parse($this->getLexer()->tokenize((string) $expression), $names);
$parsedExpression = new ParsedExpression((string) $expression, $nodes);
$this->parserCache->save($key, $parsedExpression);
$this->cache->save($key, $parsedExpression);
}
return $parsedExpression;

View File

@ -19,13 +19,18 @@ use Symfony\Component\ExpressionLanguage\ParsedExpression;
interface ParserCacheInterface
{
/**
* @param string $key
* @param ParsedExpression $data
* Saves an expression in the cache.
*
* @param string $key The cache key
* @param ParsedExpression $data A ParsedExpression instance to store in the cache
*/
public function save($key, ParsedExpression $expression);
/**
* @param string $key
* Fetches an expression from the cache.
*
* @param string $key The cache key
*
* @return ParsedExpression|null
*/
public function fetch($key);

View File

@ -1,5 +1,14 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\ExpressionLanguage\Tests;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;