Skip to content

Commit

Permalink
Simplify subscript key parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
distantnative committed Jan 20, 2025
1 parent b1bce3f commit 6ca0140
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/Query/Parser/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,15 +288,10 @@ private function memberAccess(): Node
TokenType::T_OPEN_BRACKET
])) {
if ($token->is(TokenType::T_OPEN_BRACKET) === true) {
// for subscript notation, parse the inside as
// a literal string or a full expression
if ($member = $this->consume(TokenType::T_STRING)) {
$member = new LiteralNode($member->literal);
} else {
$member = $this->expression();
}
// for subscript notation, parse the inside as expression
$member = $this->expression();

// ensure consuming the closing bracket
// and ensure consuming the closing bracket
$this->consume(
TokenType::T_CLOSE_BRACKET,
'Expect subscript closing bracket'
Expand Down

0 comments on commit 6ca0140

Please sign in to comment.