mirror of
https://github.com/danog/PHP-Parser.git
synced 2024-11-26 20:04:48 +01:00
Support error recovery for missing return type
The return type is set to "null" in this case. Fixes #544.
This commit is contained in:
parent
69068722b7
commit
3d0f7843d4
@ -1,7 +1,9 @@
|
||||
Version 4.1.1-dev
|
||||
-----------------
|
||||
|
||||
Nothing yet.
|
||||
### Added
|
||||
|
||||
* Support error recovery for missing return type (`function foo() : {}`).
|
||||
|
||||
Version 4.1.0 (2018-10-10)
|
||||
--------------------------
|
||||
|
@ -477,6 +477,7 @@ optional_param_type:
|
||||
optional_return_type:
|
||||
/* empty */ { $$ = null; }
|
||||
| ':' type_expr { $$ = $2; }
|
||||
| ':' error { $$ = null; }
|
||||
;
|
||||
|
||||
argument_list:
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1373,4 +1373,31 @@ array(
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
-----
|
||||
<?php
|
||||
function foo() :
|
||||
{
|
||||
return $a;
|
||||
}
|
||||
-----
|
||||
!!php7
|
||||
Syntax error, unexpected '{' from 3:1 to 3:1
|
||||
array(
|
||||
0: Stmt_Function(
|
||||
byRef: false
|
||||
name: Identifier(
|
||||
name: foo
|
||||
)
|
||||
params: array(
|
||||
)
|
||||
returnType: null
|
||||
stmts: array(
|
||||
0: Stmt_Return(
|
||||
expr: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
Loading…
Reference in New Issue
Block a user