/**
  * Parses an expression.
  *
  * @param Expression|string $expression The expression to parse
  * @param array             $names      An array of valid names
  *
  * @return ParsedExpression A ParsedExpression instance
  */
 public function parse($expression, $names)
 {
     if ($expression instanceof ParsedExpression) {
         return $expression;
     }
     $key = $expression . '//' . implode('-', $names);
     if (null === ($parsedExpression = $this->cache->fetch($key))) {
         $nodes = $this->getParser()->parse($this->getLexer()->tokenize((string) $expression), $names);
         $parsedExpression = new ParsedExpression((string) $expression, $nodes);
         $this->cache->save($key, $parsedExpression);
     }
     return $parsedExpression;
 }
 /**
  * Parses an expression.
  *
  * @param Expression|string $expression The expression to parse
  * @param array             $names      An array of valid names
  *
  * @return ParsedExpression A ParsedExpression instance
  */
 public function parse($expression, $names)
 {
     if ($expression instanceof ParsedExpression) {
         return $expression;
     }
     asort($names);
     $cacheKeyItems = array();
     foreach ($names as $nameKey => $name) {
         $cacheKeyItems[] = is_int($nameKey) ? $name : $nameKey . ':' . $name;
     }
     $key = $expression . '//' . implode('|', $cacheKeyItems);
     if (null === ($parsedExpression = $this->cache->fetch($key))) {
         $nodes = $this->getParser()->parse($this->getLexer()->tokenize((string) $expression), $names);
         $parsedExpression = new ParsedExpression((string) $expression, $nodes);
         $this->cache->save($key, $parsedExpression);
     }
     return $parsedExpression;
 }