]> granicus.if.org Git - php/commitdiff
Require all internal functions to have arginfo
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 13 Feb 2020 15:38:51 +0000 (16:38 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 26 Feb 2020 09:05:20 +0000 (10:05 +0100)
UPGRADING.INTERNALS
Zend/zend_API.c
Zend/zend_inheritance.c

index 6381b22d37486f9220f94666275e9f412a606a8b..af8c5218c25f3bf2363be942a624ef9a2fd83481 100644 (file)
@@ -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
 ========================
index 595208033b189cc6aa2cc05b69c51e59dc62865b..a739303cf3156975a68cc8c4e03c99c1bd204c56 100644 (file)
@@ -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) {
index 219c1ffcc9f060866f192a5f0cc4cd0cbd5ff6b9..587d4b26349911d6a63acc88d09f00d69e8d5784 100644 (file)
@@ -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
         */