/** * Parses the given docblock string for annotations. * * @param string $input The docblock string to parse. * @param string $context The parsing context. * @return array Array of annotations. If no annotations are found, an empty array is returned. */ public function parse($input, $context = '') { if (false === ($pos = strpos($input, '@'))) { return array(); } // also parse whatever character is before the @ if ($pos > 0) { $pos -= 1; } $this->context = $context; $this->lexer->setInput(trim(substr($input, $pos), '* /')); $this->lexer->moveNext(); return $this->Annotations(); }
/** * @test */ public function test_parse_return_primitive_alias() { $comment = ' /** * @Select * * foo, bar, baz * * @return int */ '; $lexer = new \Doctrine\Common\Annotations\DocLexer(); $lexer->setInput($comment); $tokens = []; while ($lexer->moveNext()) { $tokens[] = $lexer->lookahead; } }