Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. PhpDocParser.php

function PhpDocParser::parseDoctrineArgument

1 call to PhpDocParser::parseDoctrineArgument()
PhpDocParser::parseDoctrineArguments in vendor/phpstan/phpdoc-parser/src/Parser/PhpDocParser.php
*

File

vendor/phpstan/phpdoc-parser/src/Parser/PhpDocParser.php, line 625

Class

PhpDocParser
@phpstan-import-type ValueType from Doctrine\DoctrineArgument as DoctrineValueType

Namespace

PHPStan\PhpDocParser\Parser

Code

private function parseDoctrineArgument(TokenIterator $tokens) : Doctrine\DoctrineArgument {
    if (!$tokens->isCurrentTokenType(Lexer::TOKEN_IDENTIFIER)) {
        $startLine = $tokens->currentTokenLine();
        $startIndex = $tokens->currentTokenIndex();
        return $this->enrichWithAttributes($tokens, new Doctrine\DoctrineArgument(null, $this->parseDoctrineArgumentValue($tokens)), $startLine, $startIndex);
    }
    $startLine = $tokens->currentTokenLine();
    $startIndex = $tokens->currentTokenIndex();
    try {
        $tokens->pushSavePoint();
        $currentValue = $tokens->currentTokenValue();
        $tokens->consumeTokenType(Lexer::TOKEN_IDENTIFIER);
        $key = $this->enrichWithAttributes($tokens, new IdentifierTypeNode($currentValue), $startLine, $startIndex);
        $tokens->consumeTokenType(Lexer::TOKEN_EQUAL);
        $value = $this->parseDoctrineArgumentValue($tokens);
        $tokens->dropSavePoint();
        return $this->enrichWithAttributes($tokens, new Doctrine\DoctrineArgument($key, $value), $startLine, $startIndex);
    } catch (ParserException $e) {
        $tokens->rollback();
        return $this->enrichWithAttributes($tokens, new Doctrine\DoctrineArgument(null, $this->parseDoctrineArgumentValue($tokens)), $startLine, $startIndex);
    }
}
RSS feed
Powered by Drupal