mirror of
https://github.com/nikic/PHP-Parser.git
synced 2025-01-17 07:08:14 +01:00
Support declaring functions with name exit/die
For use in stubs. Fixes #1030.
This commit is contained in:
parent
26573ea64f
commit
9c7a3f8d8f
@ -464,15 +464,16 @@ block_or_error:
|
|||||||
| error { $$ = []; }
|
| error { $$ = []; }
|
||||||
;
|
;
|
||||||
|
|
||||||
identifier_maybe_readonly:
|
fn_identifier:
|
||||||
identifier_not_reserved
|
identifier_not_reserved
|
||||||
| T_READONLY { $$ = Node\Identifier[$1]; }
|
| T_READONLY { $$ = Node\Identifier[$1]; }
|
||||||
|
| T_EXIT { $$ = Node\Identifier[$1]; }
|
||||||
;
|
;
|
||||||
|
|
||||||
function_declaration_statement:
|
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' => []]]; }
|
{ $$ = 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]]; }
|
{ $$ = Stmt\Function_[$4, ['byRef' => $3, 'params' => $6, 'returnType' => $8, 'stmts' => $9, 'attrGroups' => $1]]; }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
90
test/code/parser/stmt/function/exit_die_function.test
Normal file
90
test/code/parser/stmt/function/exit_die_function.test
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
Declaring exit and die function stubs
|
||||||
|
-----
|
||||||
|
<?php
|
||||||
|
|
||||||
|
function exit(string|int $status = 0): never {}
|
||||||
|
|
||||||
|
function die(string|int $status = 0): never {}
|
||||||
|
-----
|
||||||
|
array(
|
||||||
|
0: Stmt_Function(
|
||||||
|
attrGroups: array(
|
||||||
|
)
|
||||||
|
byRef: false
|
||||||
|
name: Identifier(
|
||||||
|
name: exit
|
||||||
|
)
|
||||||
|
params: array(
|
||||||
|
0: Param(
|
||||||
|
attrGroups: array(
|
||||||
|
)
|
||||||
|
flags: 0
|
||||||
|
type: UnionType(
|
||||||
|
types: array(
|
||||||
|
0: Identifier(
|
||||||
|
name: string
|
||||||
|
)
|
||||||
|
1: Identifier(
|
||||||
|
name: int
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
byRef: false
|
||||||
|
variadic: false
|
||||||
|
var: Expr_Variable(
|
||||||
|
name: status
|
||||||
|
)
|
||||||
|
default: Scalar_Int(
|
||||||
|
value: 0
|
||||||
|
)
|
||||||
|
hooks: array(
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
returnType: Identifier(
|
||||||
|
name: never
|
||||||
|
)
|
||||||
|
stmts: array(
|
||||||
|
)
|
||||||
|
)
|
||||||
|
1: Stmt_Function(
|
||||||
|
attrGroups: array(
|
||||||
|
)
|
||||||
|
byRef: false
|
||||||
|
name: Identifier(
|
||||||
|
name: die
|
||||||
|
)
|
||||||
|
params: array(
|
||||||
|
0: Param(
|
||||||
|
attrGroups: array(
|
||||||
|
)
|
||||||
|
flags: 0
|
||||||
|
type: UnionType(
|
||||||
|
types: array(
|
||||||
|
0: Identifier(
|
||||||
|
name: string
|
||||||
|
)
|
||||||
|
1: Identifier(
|
||||||
|
name: int
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
byRef: false
|
||||||
|
variadic: false
|
||||||
|
var: Expr_Variable(
|
||||||
|
name: status
|
||||||
|
)
|
||||||
|
default: Scalar_Int(
|
||||||
|
value: 0
|
||||||
|
)
|
||||||
|
hooks: array(
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
returnType: Identifier(
|
||||||
|
name: never
|
||||||
|
)
|
||||||
|
stmts: array(
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
Loading…
x
Reference in New Issue
Block a user