Skip to content

Commit

Permalink
Disambiguate function types from private(set)
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Aug 24, 2024
1 parent e8e38f9 commit d7e1e1e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/main/php/lang/ast/syntax/PHP.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit d7e1e1e

Please sign in to comment.