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

Breadcrumb

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

function PhpDocParser::parseDoctrineArgumentValue

*

Return value

DoctrineValueType

2 calls to PhpDocParser::parseDoctrineArgumentValue()
PhpDocParser::parseDoctrineArgument in vendor/phpstan/phpdoc-parser/src/Parser/PhpDocParser.php
PhpDocParser::parseDoctrineArrayItem in vendor/phpstan/phpdoc-parser/src/Parser/PhpDocParser.php

File

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

Class

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

Namespace

PHPStan\PhpDocParser\Parser

Code

private function parseDoctrineArgumentValue(TokenIterator $tokens) {
    $startLine = $tokens->currentTokenLine();
    $startIndex = $tokens->currentTokenIndex();
    if ($tokens->isCurrentTokenType(Lexer::TOKEN_PHPDOC_TAG, Lexer::TOKEN_DOCTRINE_TAG)) {
        $name = $tokens->currentTokenValue();
        $tokens->next();
        return $this->enrichWithAttributes($tokens, new Doctrine\DoctrineAnnotation($name, $this->parseDoctrineArguments($tokens, true)), $startLine, $startIndex);
    }
    if ($tokens->tryConsumeTokenType(Lexer::TOKEN_OPEN_CURLY_BRACKET)) {
        $items = [];
        do {
            if ($tokens->isCurrentTokenType(Lexer::TOKEN_CLOSE_CURLY_BRACKET)) {
                break;
            }
            $items[] = $this->parseDoctrineArrayItem($tokens);
        } while ($tokens->tryConsumeTokenType(Lexer::TOKEN_COMMA));
        $tokens->consumeTokenType(Lexer::TOKEN_CLOSE_CURLY_BRACKET);
        return $this->enrichWithAttributes($tokens, new Doctrine\DoctrineArray($items), $startLine, $startIndex);
    }
    $currentTokenValue = $tokens->currentTokenValue();
    $tokens->pushSavePoint();
    // because of ConstFetchNode
    if ($tokens->tryConsumeTokenType(Lexer::TOKEN_IDENTIFIER)) {
        $identifier = $this->enrichWithAttributes($tokens, new Ast\Type\IdentifierTypeNode($currentTokenValue), $startLine, $startIndex);
        if (!$tokens->isCurrentTokenType(Lexer::TOKEN_DOUBLE_COLON)) {
            $tokens->dropSavePoint();
            return $identifier;
        }
        $tokens->rollback();
        // because of ConstFetchNode
    }
    else {
        $tokens->dropSavePoint();
        // because of ConstFetchNode
    }
    $currentTokenValue = $tokens->currentTokenValue();
    $currentTokenType = $tokens->currentTokenType();
    $currentTokenOffset = $tokens->currentTokenOffset();
    $currentTokenLine = $tokens->currentTokenLine();
    try {
        $constExpr = $this->doctrineConstantExprParser
            ->parse($tokens, true);
        if ($constExpr instanceof Ast\ConstExpr\ConstExprArrayNode) {
            throw new ParserException($currentTokenValue, $currentTokenType, $currentTokenOffset, Lexer::TOKEN_IDENTIFIER, null, $currentTokenLine);
        }
        return $constExpr;
    } catch (LogicException $e) {
        throw new ParserException($currentTokenValue, $currentTokenType, $currentTokenOffset, Lexer::TOKEN_IDENTIFIER, null, $currentTokenLine);
    }
}
RSS feed
Powered by Drupal