mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2024-11-26 20:14:46 +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
|
Version 4.1.1-dev
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
Nothing yet.
|
### Added
|
||||||
|
|
||||||
|
* Support error recovery for missing return type (`function foo() : {}`).
|
||||||
|
|
||||||
Version 4.1.0 (2018-10-10)
|
Version 4.1.0 (2018-10-10)
|
||||||
--------------------------
|
--------------------------
|
||||||
|
@ -477,6 +477,7 @@ optional_param_type:
|
|||||||
optional_return_type:
|
optional_return_type:
|
||||||
/* empty */ { $$ = null; }
|
/* empty */ { $$ = null; }
|
||||||
| ':' type_expr { $$ = $2; }
|
| ':' type_expr { $$ = $2; }
|
||||||
|
| ':' error { $$ = null; }
|
||||||
;
|
;
|
||||||
|
|
||||||
argument_list:
|
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