public function next($queue = true) { if ($this->eos) { return $this->currentToken; } $token = $this->tokens[$this->cursor++]; $old = $this->currentToken; $this->currentToken = $token; $this->eos = $token->getType() === Token::EOF; return $old; }