/** * Get an instance of an annotation. * * @return \com\mohiva\common\lang\annotations\Annotation An instance of an annotation. */ private function getAnnotation() { $valid = $this->stream->moveTo(AnnotationLexer::T_IDENTIFIER); if (!$valid) { return null; } $name = $this->getName(); if ($this->stream->isNext(AnnotationLexer::T_OPEN_PARENTHESIS)) { $params = $this->getParams(); } else { $params = array(); } return $this->getAnnotationInstance($name, $params); }
/** * Test if can move to a specified token. * * @param \com\mohiva\common\parser\TokenStream $stream The token stream to use for this test. * @dataProvider tokenStreamProvider */ public function testMoveTo(TokenStream $stream) { // user.name.split(" ").join("-") $moved = $stream->moveTo(self::T_POINT); $current = $stream->current(); $this->assertTrue($moved); $this->assertSame($current->getCode(), self::T_POINT); $moved = $stream->moveTo(self::T_POINT); $current = $stream->current(); $this->assertTrue($moved); $this->assertSame($current->getCode(), self::T_POINT); $moved = $stream->moveTo(self::T_VALUE); $current = $stream->current(); $this->assertTrue($moved); $this->assertSame($current->getCode(), self::T_VALUE); $moved = $stream->moveTo(self::T_OPEN_PARENTHESIS); $current = $stream->current(); $this->assertTrue($moved); $this->assertSame($current->getCode(), self::T_OPEN_PARENTHESIS); $moved = $stream->moveTo(self::T_CLOSE_PARENTHESIS); $current = $stream->current(); $this->assertTrue($moved); $this->assertSame($current->getCode(), self::T_CLOSE_PARENTHESIS); $moved = $stream->moveTo(self::T_NAME); $this->assertFalse($moved); }