function DocParser::Values

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

Values ::= Array | Value {"," Value}* [","]

Return value

array

1 call to DocParser::Values()
DocParser::MethodCall in core/lib/Drupal/Component/Annotation/Doctrine/DocParser.php
MethodCall ::= ["(" [Values] ")"]

File

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

Class

DocParser
A parser for docblock annotations.

Namespace

Drupal\Component\Annotation\Doctrine

Code

private function Values() {
    $values = array(
        $this->Value(),
    );
    while ($this->lexer
        ->isNextToken(DocLexer::T_COMMA)) {
        $this->match(DocLexer::T_COMMA);
        if ($this->lexer
            ->isNextToken(DocLexer::T_CLOSE_PARENTHESIS)) {
            break;
        }
        $token = $this->lexer->lookahead;
        $value = $this->Value();
        if (!is_object($value) && !is_array($value)) {
            $this->syntaxError('Value', $token);
        }
        $values[] = $value;
    }
    foreach ($values as $k => $value) {
        if (is_object($value) && $value instanceof \stdClass) {
            $values[$value->name] = $value->value;
        }
        else {
            if (!isset($values['value'])) {
                $values['value'] = $value;
            }
            else {
                if (!is_array($values['value'])) {
                    $values['value'] = array(
                        $values['value'],
                    );
                }
                $values['value'][] = $value;
            }
        }
        unset($values[$k]);
    }
    return $values;
}

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