From 9ba243b6f385a1f38f6f180d0dbf82928f15341c Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sat, 4 Jun 2016 14:53:50 +0200 Subject: [PATCH] Forbid ?void --- Zend/tests/type_declarations/nullable_void.phpt | 11 +++++++++++ Zend/zend_compile.c | 4 ++++ 2 files changed, 15 insertions(+) create mode 100644 Zend/tests/type_declarations/nullable_void.phpt diff --git a/Zend/tests/type_declarations/nullable_void.phpt b/Zend/tests/type_declarations/nullable_void.phpt new file mode 100644 index 0000000000..4ff0edb0d8 --- /dev/null +++ b/Zend/tests/type_declarations/nullable_void.phpt @@ -0,0 +1,11 @@ +--TEST-- +Void cannot be nullable +--FILE-- + +--EXPECTF-- +Fatal error: Void type cannot be nullable in %s on line %d diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 2a575cff62..ce8224652d 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -4964,6 +4964,10 @@ void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast) /* {{{ */ zend_compile_typename(return_type_ast, arg_infos); + if (arg_infos->type_hint == IS_VOID && arg_infos->allow_null) { + zend_error_noreturn(E_COMPILE_ERROR, "Void type cannot be nullable"); + } + arg_infos++; op_array->fn_flags |= ZEND_ACC_HAS_RETURN_TYPE; } else { -- 2.50.1