createForInvalidExpressionLanguageToken() public static method

public static createForInvalidExpressionLanguageToken ( string $value ) : InvalidArgumentException
$value string
return InvalidArgumentException
コード例 #1
0
 public function testTestCreateForInvalidExpressionLanguageToken()
 {
     $exception = InvalidArgumentExceptionFactory::createForInvalidExpressionLanguageToken('foo');
     $this->assertEquals('Invalid token "foo" found.', $exception->getMessage());
     $this->assertEquals(0, $exception->getCode());
     $this->assertNull($exception->getPrevious());
 }
コード例 #2
0
ファイル: GlobalPatternsLexer.php プロジェクト: nelmio/alice
 /**
  * {@inheritdoc}
  *
  * @throws LexException
  */
 public function lex(string $value) : array
 {
     foreach (self::PATTERNS as $pattern => $tokenTypeConstant) {
         if (1 === preg_match($pattern, $value, $matches)) {
             if (null === $tokenTypeConstant) {
                 throw InvalidArgumentExceptionFactory::createForInvalidExpressionLanguageToken($value);
             }
             return [new Token($matches[0], new TokenType($tokenTypeConstant))];
         }
     }
     return $this->lexer->lex($value);
 }
コード例 #3
0
ファイル: SubPatternsLexer.php プロジェクト: nelmio/alice
 /**
  * @param LexerInterface $referenceLexer
  * @param string         $valueFragment
  *
  * @throws LexException
  *
  * @return Token[]
  */
 private function lexFragment(LexerInterface $referenceLexer, string $valueFragment) : array
 {
     foreach (self::PATTERNS as $pattern => $tokenTypeConstant) {
         if (1 === preg_match($pattern, $valueFragment, $matches)) {
             if (null === $tokenTypeConstant) {
                 throw InvalidArgumentExceptionFactory::createForInvalidExpressionLanguageToken($valueFragment);
             }
             $match = $matches[1];
             if (self::REFERENCE_LEXER === $tokenTypeConstant) {
                 return $referenceLexer->lex($match);
             }
             return [new Token($match, new TokenType($tokenTypeConstant))];
         }
     }
     throw ExpressionLanguageExceptionFactory::createForCouldNotLexValue($valueFragment);
 }