function ConstExprParser::parseArrayItem
1 call to ConstExprParser::parseArrayItem()
- ConstExprParser::parseArray in vendor/
phpstan/ phpdoc-parser/ src/ Parser/ ConstExprParser.php
File
-
vendor/
phpstan/ phpdoc-parser/ src/ Parser/ ConstExprParser.php, line 289
Class
Namespace
PHPStan\PhpDocParser\ParserCode
private function parseArrayItem(TokenIterator $tokens) : Ast\ConstExpr\ConstExprArrayItemNode {
$startLine = $tokens->currentTokenLine();
$startIndex = $tokens->currentTokenIndex();
$expr = $this->parse($tokens);
if ($tokens->tryConsumeTokenType(Lexer::TOKEN_DOUBLE_ARROW)) {
$key = $expr;
$value = $this->parse($tokens);
}
else {
$key = null;
$value = $expr;
}
return $this->enrichWithAttributes($tokens, new Ast\ConstExpr\ConstExprArrayItemNode($key, $value), $startLine, $startIndex);
}