File tree Expand file tree Collapse file tree 3 files changed +81
-0
lines changed
test/code/parser/stmt/function Expand file tree Collapse file tree 3 files changed +81
-0
lines changed Original file line number Diff line number Diff line change @@ -1078,6 +1078,13 @@ protected function checkParam(Param $node): void {
10781078 $ node ->default ->getAttributes ()
10791079 ));
10801080 }
1081+
1082+ if ($ node ->type instanceof Identifier && $ node ->type ->name === 'void ' ) {
1083+ $ this ->emitError (new Error (
1084+ 'Parameter type cannot be void ' ,
1085+ $ node ->type ->getAttributes ()
1086+ ));
1087+ }
10811088 }
10821089
10831090 protected function checkTryCatch (TryCatch $ node ): void {
Original file line number Diff line number Diff line change 1+ Invalid parameter with type void
2+ -----
3+ <?php
4+ function foo(void $foo) {}
5+ -----
6+ Parameter type cannot be void from 2:14 to 2:17
7+ array(
8+ 0: Stmt_Function(
9+ attrGroups: array(
10+ )
11+ byRef: false
12+ name: Identifier(
13+ name: foo
14+ )
15+ params: array(
16+ 0: Param(
17+ attrGroups: array(
18+ )
19+ flags: 0
20+ type: Identifier(
21+ name: void
22+ )
23+ byRef: false
24+ variadic: false
25+ var: Expr_Variable(
26+ name: foo
27+ )
28+ default: null
29+ hooks: array(
30+ )
31+ )
32+ )
33+ returnType: null
34+ stmts: array(
35+ )
36+ )
37+ )
Original file line number Diff line number Diff line change 1+ Valid parameter with type void
2+ -----
3+ <?php
4+ function foo(void $foo) {}
5+ -----
6+ !!version=7.0
7+ array(
8+ 0: Stmt_Function(
9+ attrGroups: array(
10+ )
11+ byRef: false
12+ name: Identifier(
13+ name: foo
14+ )
15+ params: array(
16+ 0: Param(
17+ attrGroups: array(
18+ )
19+ flags: 0
20+ type: Name(
21+ name: void
22+ )
23+ byRef: false
24+ variadic: false
25+ var: Expr_Variable(
26+ name: foo
27+ )
28+ default: null
29+ hooks: array(
30+ )
31+ )
32+ )
33+ returnType: null
34+ stmts: array(
35+ )
36+ )
37+ )
You can’t perform that action at this time.
0 commit comments