isEOF()) { $token = $stream->next(); $repr[] = $token->getValue(); } $this->assertEquals('1, 2, 3, 4, 5, 6, 7', implode(', ', $repr), '->next() advances the pointer and returns the current token'); } public function testEndOfTemplateNext() { $stream = new TokenStream([ new Token(Token::BLOCK_START_TYPE, 1, 1), ], new Source('', '')); $this->expectException(SyntaxError::class); $this->expectExceptionMessage('Unexpected end of template'); while (!$stream->isEOF()) { $stream->next(); } } public function testEndOfTemplateLook() { $stream = new TokenStream([ new Token(Token::BLOCK_START_TYPE, 1, 1), ], new Source('', '')); $this->expectException(SyntaxError::class); $this->expectExceptionMessage('Unexpected end of template'); while (!$stream->isEOF()) { $stream->look(); $stream->next(); } } }