SqlParser\TokensList::getNextOfTypeAndValue PHP 메소드

getNextOfTypeAndValue() 공개 메소드

Gets the next token.
public getNextOfTypeAndValue ( integer $type, string $value ) : Token
$type integer The type of the token.
$value string The value of the token.
리턴 Token
    public function getNextOfTypeAndValue($type, $value)
    {
        for (; $this->idx < $this->count; ++$this->idx) {
            if ($this->tokens[$this->idx]->type === $type && $this->tokens[$this->idx]->value === $value) {
                return $this->tokens[$this->idx++];
            }
        }
        return null;
    }

Usage Example

 /**
  * Function called before the token is processed.
  *
  * Skips the `TABLE` keyword after `RENAME`.
  *
  * @param Parser     $parser The instance that requests parsing.
  * @param TokensList $list   The list of tokens to be parsed.
  * @param Token      $token  The token that is being parsed.
  *
  * @return void
  */
 public function before(Parser $parser, TokensList $list, Token $token)
 {
     if ($token->type === Token::TYPE_KEYWORD && $token->value === 'RENAME') {
         // Checking if it is the beginning of the query.
         $list->getNextOfTypeAndValue(Token::TYPE_KEYWORD, 'TABLE');
     }
 }
All Usage Examples Of SqlParser\TokensList::getNextOfTypeAndValue