From 012ec21def16f8327d13da1ae9e77697d361f4b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Sun, 24 Dec 2023 14:14:35 +0100 Subject: [PATCH] Remove unused parameter from zend_compile_typename() The force_allow_null parameter is always false, therefore it is not needed. This simplification paves the road for deprecating implicitly nullable parameter types. --- Zend/zend_compile.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 1078dd1d20a..afce5150e08 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -6560,7 +6560,7 @@ static void zend_is_type_list_redundant_by_single_type(zend_type_list *type_list } } -static zend_type zend_compile_typename(zend_ast *ast, bool force_allow_null); +static zend_type zend_compile_typename(zend_ast *ast); static zend_type zend_compile_typename_ex( zend_ast *ast, bool force_allow_null, bool *forced_allow_null) /* {{{ */ @@ -6601,7 +6601,7 @@ static zend_type zend_compile_typename_ex( /* Mark type as list type */ ZEND_TYPE_SET_LIST(type, type_list); - single_type = zend_compile_typename(type_ast, false); + single_type = zend_compile_typename(type_ast); ZEND_ASSERT(ZEND_TYPE_IS_INTERSECTION(single_type)); type_list->types[type_list->num_types++] = single_type; @@ -6788,10 +6788,10 @@ static zend_type zend_compile_typename_ex( } /* }}} */ -static zend_type zend_compile_typename(zend_ast *ast, bool force_allow_null) +static zend_type zend_compile_typename(zend_ast *ast) { bool forced_allow_null; - return zend_compile_typename_ex(ast, force_allow_null, &forced_allow_null); + return zend_compile_typename_ex(ast, false, &forced_allow_null); } /* May convert value from int to float. */ @@ -6937,8 +6937,7 @@ static void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast, uint32 arg_infos = safe_emalloc(sizeof(zend_arg_info), list->children + 1, 0); arg_infos->name = NULL; if (return_type_ast) { - arg_infos->type = zend_compile_typename( - return_type_ast, /* force_allow_null */ 0); + arg_infos->type = zend_compile_typename(return_type_ast); ZEND_TYPE_FULL_MASK(arg_infos->type) |= _ZEND_ARG_INFO_FLAGS( (op_array->fn_flags & ZEND_ACC_RETURN_REFERENCE) != 0, /* is_variadic */ 0, /* is_tentative */ 0); } else { @@ -7141,7 +7140,7 @@ static void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast, uint32 /* Recompile the type, as it has different memory management requirements. */ zend_type type = ZEND_TYPE_INIT_NONE(0); if (type_ast) { - type = zend_compile_typename(type_ast, /* force_allow_null */ 0); + type = zend_compile_typename(type_ast); } /* Don't give the property an explicit default value. For typed properties this means @@ -7715,7 +7714,7 @@ static void zend_compile_prop_decl(zend_ast *ast, zend_ast *type_ast, uint32_t f zend_type type = ZEND_TYPE_INIT_NONE(0); if (type_ast) { - type = zend_compile_typename(type_ast, /* force_allow_null */ 0); + type = zend_compile_typename(type_ast); if (ZEND_TYPE_FULL_MASK(type) & (MAY_BE_VOID|MAY_BE_NEVER|MAY_BE_CALLABLE)) { zend_string *str = zend_type_to_string(type); @@ -7830,7 +7829,7 @@ static void zend_compile_class_const_decl(zend_ast *ast, uint32_t flags, zend_as zend_type type = ZEND_TYPE_INIT_NONE(0); if (type_ast) { - type = zend_compile_typename(type_ast, /* force_allow_null */ 0); + type = zend_compile_typename(type_ast); uint32_t type_mask = ZEND_TYPE_PURE_MASK(type); @@ -8023,7 +8022,7 @@ static zend_string *zend_generate_anon_class_name(zend_ast_decl *decl) static void zend_compile_enum_backing_type(zend_class_entry *ce, zend_ast *enum_backing_type_ast) { ZEND_ASSERT(ce->ce_flags & ZEND_ACC_ENUM); - zend_type type = zend_compile_typename(enum_backing_type_ast, 0); + zend_type type = zend_compile_typename(enum_backing_type_ast); uint32_t type_mask = ZEND_TYPE_PURE_MASK(type); if (ZEND_TYPE_IS_COMPLEX(type) || (type_mask != MAY_BE_LONG && type_mask != MAY_BE_STRING)) { zend_string *type_string = zend_type_to_string(type);