function DocParser::Annotations

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Component/Annotation/Doctrine/DocParser.php \Drupal\Component\Annotation\Doctrine\DocParser::Annotations()
  2. 8.9.x core/lib/Drupal/Component/Annotation/Doctrine/DocParser.php \Drupal\Component\Annotation\Doctrine\DocParser::Annotations()
  3. 10 core/lib/Drupal/Component/Annotation/Doctrine/DocParser.php \Drupal\Component\Annotation\Doctrine\DocParser::Annotations()

Annotations ::= Annotation {[ "*" ]* [Annotation]}*

Return value

array

1 call to DocParser::Annotations()
DocParser::parse in core/lib/Drupal/Component/Annotation/Doctrine/DocParser.php
Parses the given docblock string for annotations.

File

core/lib/Drupal/Component/Annotation/Doctrine/DocParser.php, line 614

Class

DocParser
A parser for docblock annotations.

Namespace

Drupal\Component\Annotation\Doctrine

Code

private function Annotations() {
    $annotations = array();
    while (null !== $this->lexer->lookahead) {
        if (DocLexer::T_AT !== $this->lexer->lookahead['type']) {
            $this->lexer
                ->moveNext();
            continue;
        }
        // make sure the @ is preceded by non-catchable pattern
        if (null !== $this->lexer->token && $this->lexer->lookahead['position'] === $this->lexer->token['position'] + strlen($this->lexer->token['value'])) {
            $this->lexer
                ->moveNext();
            continue;
        }
        // make sure the @ is followed by either a namespace separator, or
        // an identifier token
        if (null === ($peek = $this->lexer
            ->glimpse()) || DocLexer::T_NAMESPACE_SEPARATOR !== $peek['type'] && !in_array($peek['type'], self::$classIdentifiers, true) || $peek['position'] !== $this->lexer->lookahead['position'] + 1) {
            $this->lexer
                ->moveNext();
            continue;
        }
        $this->isNestedAnnotation = false;
        if (false !== ($annotation = $this->Annotation())) {
            $annotations[] = $annotation;
        }
    }
    return $annotations;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.