示例#1
0
 protected function _DocBlock(DocblockLexer $lexer, $location, $namespaces)
 {
     $annotations = array();
     while ($lexer->skipToType(DocblockLexer::T_PREAMBLE)) {
         $next = $lexer->next();
         if ($next["type"] !== DocblockLexer::T_AT) {
             // Skip because it doesn't have an annotation at the start
             continue;
         }
         $pos = $lexer->cur();
         try {
             $annotation = $this->_Annotation($lexer, $location, $namespaces);
             $this->_expectNext($lexer, DocblockLexer::$TREAT_AS_WS);
             if (isset($annotation)) {
                 $annotations[$annotation[0]][] = $annotation[1];
             } else {
                 // If not then it parsed fine, but it isn't something we know about
             }
         } catch (\Exception $e) {
             // OK, try starting 1 char after the @ to find the next annotation.
             if ($this->logger) {
                 $this->logger->debug("Skipping syntax error: " . $e->getMessage(), array("exception" => $e));
             }
             $lexer->seek($pos);
             if (!$lexer->next()) {
                 break;
             }
         }
     }
     return $annotations;
 }
示例#2
0
 /**
  * @covers \Weasel\Annotation\DocblockLexer::skipToType
  */
 public function testSkipToTypeEmpty()
 {
     $lexer = new DocblockLexer("");
     $this->assertNull($lexer->skipToType(DocblockLexer::T_AT));
 }