From b7745d6eeb39dffc616ef48b92b6b2cfc7e571a5 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 23 Sep 2019 15:59:47 +0200 Subject: [PATCH] Check for nullable void type earlier --- Zend/zend_compile.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 986584c690e..373792548f2 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -5323,6 +5323,9 @@ static zend_type zend_compile_typename(zend_ast *ast, zend_bool force_allow_null "Type declaration '%s' must be unqualified", ZSTR_VAL(zend_string_tolower(class_name))); } + if (type == IS_VOID && allow_null) { + zend_error_noreturn(E_COMPILE_ERROR, "Void type cannot be nullable"); + } return ZEND_TYPE_ENCODE_CODE(type, allow_null); } else { uint32_t fetch_type = zend_get_class_fetch_type_ast(ast); @@ -5354,13 +5357,6 @@ void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast) /* {{{ */ arg_infos->pass_by_reference = (op_array->fn_flags & ZEND_ACC_RETURN_REFERENCE) != 0; arg_infos->is_variadic = 0; arg_infos->type = zend_compile_typename(return_type_ast, 0); - - if (ZEND_TYPE_IS_MASK(arg_infos->type) - && ZEND_TYPE_CONTAINS_CODE(arg_infos->type, IS_VOID) - && ZEND_TYPE_ALLOW_NULL(arg_infos->type)) { - zend_error_noreturn(E_COMPILE_ERROR, "Void type cannot be nullable"); - } - arg_infos++; op_array->fn_flags |= ZEND_ACC_HAS_RETURN_TYPE; } else {