Skip to content

Commit

Permalink
Add support for PHP 8.4 exit function
Browse files Browse the repository at this point in the history
For backwards-compatibility, parse the simple single argument
case into an Exit_ node as previously. For more complex
expressions generate a function call.
  • Loading branch information
nikic committed Sep 1, 2024
1 parent 018da15 commit cde9bab
Show file tree
Hide file tree
Showing 5 changed files with 1,259 additions and 1,140 deletions.
11 changes: 2 additions & 9 deletions grammar/php.y
Original file line number Diff line number Diff line change
Expand Up @@ -1068,10 +1068,8 @@ expr:
| T_OBJECT_CAST expr { $$ = Expr\Cast\Object_ [$2]; }
| T_BOOL_CAST expr { $$ = Expr\Cast\Bool_ [$2]; }
| T_UNSET_CAST expr { $$ = Expr\Cast\Unset_ [$2]; }
| T_EXIT exit_expr
{ $attrs = attributes();
$attrs['kind'] = strtolower($1) === 'exit' ? Expr\Exit_::KIND_EXIT : Expr\Exit_::KIND_DIE;
$$ = new Expr\Exit_($2, $attrs); }
| T_EXIT ctor_arguments
{ $$ = $this->createExitExpr($1, #1, $2, attributes()); }
| '@' expr { $$ = Expr\ErrorSuppress[$2]; }
| scalar
| '`' backticks_expr '`' { $$ = Expr\ShellExec[$2]; }
Expand Down Expand Up @@ -1176,11 +1174,6 @@ class_name_or_var:
| fully_dereferenceable
;

exit_expr:
/* empty */ { $$ = null; }
| '(' optional_expr ')' { $$ = $2; }
;

backticks_expr:
/* empty */ { $$ = array(); }
| encaps_string_part
Expand Down
Loading

0 comments on commit cde9bab

Please sign in to comment.