/** * @covers \Weasel\Annotation\DocblockLexer::peek * @covers \Weasel\Annotation\DocblockLexer::cur * @covers \Weasel\Annotation\DocblockLexer::_wsSkippingPeek */ public function testPeek() { $testIn = '@ 1 \\ true "foo" bar'; $lexer = new DocblockLexer($testIn); $cur = $lexer->cur(); $this->assertEquals(DocblockLexer::T_AT, $lexer->peek(0)); $this->assertEquals(DocblockLexer::T_WHITESPACE, $lexer->peek(1)); $this->assertEquals(DocblockLexer::T_INTEGER, $lexer->peek(2)); $this->assertEquals(DocblockLexer::T_IDENTIFIER, $lexer->peek(10)); $this->assertNull($lexer->peek(11)); $this->assertEquals(DocblockLexer::T_AT, $lexer->peek(0, true)); $this->assertEquals(DocblockLexer::T_INTEGER, $lexer->peek(1, true)); $this->assertEquals(DocblockLexer::T_BACKSLASH, $lexer->peek(2, true)); $this->assertEquals(DocblockLexer::T_BOOLEAN, $lexer->peek(3, true)); $this->assertEquals(DocblockLexer::T_IDENTIFIER, $lexer->peek(5, true)); $this->assertNull($lexer->peek(6, true)); $this->assertEquals(DocblockLexer::T_INTEGER, $lexer->peek(1, true)); $this->assertEquals($cur, $lexer->cur()); $lexer->next(); $this->assertEquals(DocblockLexer::T_INTEGER, $lexer->peek(0, true)); }
protected function _ClassName(DocblockLexer $lexer) { $next = $lexer->next(); $class = ''; if ($next['type'] === DocblockLexer::T_BACKSLASH) { $class .= '\\'; $next = $this->_expectNext($lexer, DocblockLexer::T_IDENTIFIER); } $class .= $next['token']; while ($lexer->peek() === DocblockLexer::T_BACKSLASH) { $this->_expectNext($lexer, DocblockLexer::T_BACKSLASH); $class .= '\\'; $part = $this->_expectNext($lexer, DocblockLexer::T_IDENTIFIER); $class .= $part['token']; } return $class; }