Skip to content

Commit 9ba243b

Browse files
committed
Forbid ?void
1 parent 73b2f79 commit 9ba243b

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
Void cannot be nullable
3+
--FILE--
4+
<?php
5+
6+
function test() : ?void {
7+
}
8+
9+
?>
10+
--EXPECTF--
11+
Fatal error: Void type cannot be nullable in %s on line %d

Zend/zend_compile.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4964,6 +4964,10 @@ void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast) /* {{{ */
49644964

49654965
zend_compile_typename(return_type_ast, arg_infos);
49664966

4967+
if (arg_infos->type_hint == IS_VOID && arg_infos->allow_null) {
4968+
zend_error_noreturn(E_COMPILE_ERROR, "Void type cannot be nullable");
4969+
}
4970+
49674971
arg_infos++;
49684972
op_array->fn_flags |= ZEND_ACC_HAS_RETURN_TYPE;
49694973
} else {

0 commit comments

Comments
 (0)