Skip to content

Commit

Permalink
Support declaring functions with name exit/die
Browse files Browse the repository at this point in the history
For use in stubs.

Fixes #1030.
  • Loading branch information
nikic committed Oct 8, 2024
1 parent 26573ea commit 9c7a3f8
Show file tree
Hide file tree
Showing 4 changed files with 1,863 additions and 1,768 deletions.
7 changes: 4 additions & 3 deletions grammar/php.y
Original file line number Diff line number Diff line change
Expand Up @@ -464,15 +464,16 @@ block_or_error:
| error { $$ = []; }
;

identifier_maybe_readonly:
fn_identifier:
identifier_not_reserved
| T_READONLY { $$ = Node\Identifier[$1]; }
| T_EXIT { $$ = Node\Identifier[$1]; }
;

function_declaration_statement:
T_FUNCTION optional_ref identifier_maybe_readonly '(' parameter_list ')' optional_return_type block_or_error
T_FUNCTION optional_ref fn_identifier '(' parameter_list ')' optional_return_type block_or_error
{ $$ = Stmt\Function_[$3, ['byRef' => $2, 'params' => $5, 'returnType' => $7, 'stmts' => $8, 'attrGroups' => []]]; }
| attributes T_FUNCTION optional_ref identifier_maybe_readonly '(' parameter_list ')' optional_return_type block_or_error
| attributes T_FUNCTION optional_ref fn_identifier '(' parameter_list ')' optional_return_type block_or_error
{ $$ = Stmt\Function_[$4, ['byRef' => $3, 'params' => $6, 'returnType' => $8, 'stmts' => $9, 'attrGroups' => $1]]; }
;

Expand Down
Loading

0 comments on commit 9c7a3f8

Please sign in to comment.