From: Nikita Popov Date: Thu, 13 Feb 2020 15:38:51 +0000 (+0100) Subject: Require all internal functions to have arginfo X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b35b0142e68458475df03c24e622f1c4173ff68b;p=php Require all internal functions to have arginfo --- diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 6381b22d37..af8c5218c2 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -13,6 +13,7 @@ PHP 8.0 INTERNALS UPGRADE NOTES j. compare_objects() and compare() object handlers k. The 'I' length modifier l. Some VM instructions switched to IS_TMP_VAR result instead of IS_VAR + m. All internal functions must have arginfo 2. Build system changes a. Abstract @@ -98,6 +99,9 @@ PHP 8.0 INTERNALS UPGRADE NOTES pre increments/decrements (ZEND_PRE_INC, ZEND_PRE_DEC, ZEND_PRE_INC_OBJ ZEND_PRE_DEC_OBJ, ZEND_PRE_INC_STATIC_PROP ZEND_PRE_DEC_STATIC_PROP). + m. All internal functions and methods are now required to specify arginfo + information, otherwise warnings will be thrown on startup. + ======================== 2. Build system changes ======================== diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 595208033b..a739303cf3 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -2042,9 +2042,9 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio } else { internal_function->fn_flags = ZEND_ACC_PUBLIC; } + if (ptr->arg_info) { zend_internal_function_info *info = (zend_internal_function_info*)ptr->arg_info; - internal_function->arg_info = (zend_internal_arg_info*)ptr->arg_info+1; internal_function->num_args = ptr->num_args; /* Currently you cannot denote that the function can accept less arguments than num_args */ @@ -2072,10 +2072,14 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio internal_function->fn_flags |= ZEND_ACC_HAS_RETURN_TYPE; } } else { + zend_error(E_CORE_WARNING, "Missing arginfo for %s%s%s()", + scope ? ZSTR_VAL(scope->name) : "", scope ? "::" : "", ptr->fname); + internal_function->arg_info = NULL; internal_function->num_args = 0; internal_function->required_num_args = 0; } + zend_set_function_arg_flags((zend_function*)internal_function); if (ptr->flags & ZEND_ACC_ABSTRACT) { if (scope) { diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index 219c1ffcc9..587d4b2634 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -530,14 +530,6 @@ static inheritance_status zend_do_perform_implementation_check( inheritance_status status, local_status; zend_bool proto_is_variadic, fe_is_variadic; - /* If it's a user function then arg_info == NULL means we don't have any parameters but - * we still need to do the arg number checks. We are only willing to ignore this for internal - * functions because extensions don't always define arg_info. - */ - if (!proto->common.arg_info && proto->common.type != ZEND_USER_FUNCTION) { - return INHERITANCE_SUCCESS; - } - /* Checks for constructors only if they are declared in an interface, * or explicitly marked as abstract */