Inheritance: use trait Nelmio\Alice\IsAServiceTrait
Beispiel #1
0
 /**
  * {@inheritdoc}
  *
  * @throws MalformedFunctionException
  */
 public function lex(string $value) : array
 {
     if (false === $this->functionTokenizer->isTokenized($value)) {
         $value = $this->functionTokenizer->tokenize($value);
     }
     return $this->decoratedLexer->lex($value);
 }
 /**
  * Parses '<<', '@@'...
  *
  * {@inheritdoc}
  */
 public function parse(Token $token) : string
 {
     $value = $token->getValue();
     if ('' === $value) {
         throw ExpressionLanguageExceptionFactory::createForUnparsableToken($token);
     }
     return $this->tokenizer->detokenize(substr($value, 1));
 }
Beispiel #3
0
 /**
  * @dataProvider provideValues
  */
 public function testTokenizeValues($value, $expected)
 {
     try {
         $actual = $this->tokenizer->tokenize($value);
         if (null === $expected) {
             $this->fail('Expected exception to be thrown.');
         }
         $this->assertEquals($expected, $actual);
     } catch (MalformedFunctionException $exception) {
         if (null !== $expected) {
             throw $exception;
         }
     }
 }
Beispiel #4
0
 /**
  * Parses expressions such as '<(something)>'.
  *
  * {@inheritdoc}
  *
  * @throws ParseException
  */
 public function parse(Token $token)
 {
     $value = $this->tokenizer->detokenize($token->getValue());
     $realValue = preg_replace('/^<\\((.*)\\)>$/', '<identity($1)>', $value);
     return $this->decoratedTokenParser->parse(new Token($realValue, new TokenType(TokenType::FUNCTION_TYPE)));
 }