Skip to content

Commit cde9bab

Browse files
committed
Add support for PHP 8.4 exit function
For backwards-compatibility, parse the simple single argument case into an Exit_ node as previously. For more complex expressions generate a function call.
1 parent 018da15 commit cde9bab

File tree

5 files changed

+1259
-1140
lines changed

5 files changed

+1259
-1140
lines changed

grammar/php.y

+2-9
Original file line numberDiff line numberDiff line change
@@ -1068,10 +1068,8 @@ expr:
10681068
| T_OBJECT_CAST expr { $$ = Expr\Cast\Object_ [$2]; }
10691069
| T_BOOL_CAST expr { $$ = Expr\Cast\Bool_ [$2]; }
10701070
| T_UNSET_CAST expr { $$ = Expr\Cast\Unset_ [$2]; }
1071-
| T_EXIT exit_expr
1072-
{ $attrs = attributes();
1073-
$attrs['kind'] = strtolower($1) === 'exit' ? Expr\Exit_::KIND_EXIT : Expr\Exit_::KIND_DIE;
1074-
$$ = new Expr\Exit_($2, $attrs); }
1071+
| T_EXIT ctor_arguments
1072+
{ $$ = $this->createExitExpr($1, #1, $2, attributes()); }
10751073
| '@' expr { $$ = Expr\ErrorSuppress[$2]; }
10761074
| scalar
10771075
| '`' backticks_expr '`' { $$ = Expr\ShellExec[$2]; }
@@ -1176,11 +1174,6 @@ class_name_or_var:
11761174
| fully_dereferenceable
11771175
;
11781176

1179-
exit_expr:
1180-
/* empty */ { $$ = null; }
1181-
| '(' optional_expr ')' { $$ = $2; }
1182-
;
1183-
11841177
backticks_expr:
11851178
/* empty */ { $$ = array(); }
11861179
| encaps_string_part

0 commit comments

Comments
 (0)