You are here

private function DocParser::ArrayEntry in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Component/Annotation/Doctrine/DocParser.php \Drupal\Component\Annotation\Doctrine\DocParser::ArrayEntry()

ArrayEntry ::= Value | KeyValuePair KeyValuePair ::= Key ("=" | ":") PlainValue | Constant Key ::= string | integer | Constant

Return value

array

1 call to DocParser::ArrayEntry()
DocParser::Arrayx in core/lib/Drupal/Component/Annotation/Doctrine/DocParser.php
Array ::= "{" ArrayEntry {"," ArrayEntry}* [","] "}"

File

core/lib/Drupal/Component/Annotation/Doctrine/DocParser.php, line 1121
This class is a near-copy of Doctrine\Common\Annotations\DocParser, which is part of the Doctrine project: <http://www.doctrine-project.org>. It was copied from version 1.2.7.

Class

DocParser
A parser for docblock annotations.

Namespace

Drupal\Component\Annotation\Doctrine

Code

private function ArrayEntry() {
  $peek = $this->lexer
    ->glimpse();
  if (DocLexer::T_EQUALS === $peek['type'] || DocLexer::T_COLON === $peek['type']) {
    if ($this->lexer
      ->isNextToken(DocLexer::T_IDENTIFIER)) {
      $key = $this
        ->Constant();
    }
    else {
      $this
        ->matchAny(array(
        DocLexer::T_INTEGER,
        DocLexer::T_STRING,
      ));
      $key = $this->lexer->token['value'];
    }
    $this
      ->matchAny(array(
      DocLexer::T_EQUALS,
      DocLexer::T_COLON,
    ));
    return array(
      $key,
      $this
        ->PlainValue(),
    );
  }
  return array(
    null,
    $this
      ->Value(),
  );
}