From d7e1e1eb778ccb7f5708552d7377d08412bc365b Mon Sep 17 00:00:00 2001 From: Timm Friebe Date: Sat, 24 Aug 2024 12:37:05 +0200 Subject: [PATCH] Disambiguate function types from `private(set)` --- src/main/php/lang/ast/syntax/PHP.class.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/php/lang/ast/syntax/PHP.class.php b/src/main/php/lang/ast/syntax/PHP.class.php index 5c31237..114c171 100755 --- a/src/main/php/lang/ast/syntax/PHP.class.php +++ b/src/main/php/lang/ast/syntax/PHP.class.php @@ -1477,16 +1477,25 @@ private function annotations($parse, $context) { } private function modifier($parse) { - $token= $parse->token->value; + $modifier= $parse->token->value; $parse->forward(); if ('(' === $parse->token->value) { + $token= $parse->token; $parse->expecting('(', 'modifiers'); - $token.= '('.$parse->token->value.')'; + + // Disambiguate function types from `private(set)` + if ('function' === $parse->token->value) { + array_unshift($parse->queue, $parse->token); + $parse->token= $token; + return $modifier; + } + + $modifier.= '('.$parse->token->value.')'; $parse->forward(); $parse->expecting(')', 'modifiers'); } - return $token; + return $modifier; } private function parameters($parse) {