]> granicus.if.org Git - php/commitdiff
Don't check argument types for internal functions without type hinting
authorDmitry Stogov <dmitry@zend.com>
Thu, 28 Nov 2013 07:44:14 +0000 (11:44 +0400)
committerDmitry Stogov <dmitry@zend.com>
Thu, 28 Nov 2013 07:44:14 +0000 (11:44 +0400)
Zend/zend_API.c
Zend/zend_compile.h
Zend/zend_vm_def.h
Zend/zend_vm_execute.h

index 56b1fda24b659e42241818bae21b2615a37aab47..23729ea185a65e24838a373145d54313a9e3d858 100644 (file)
@@ -2138,6 +2138,19 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
                        str_efree(lowercase_name);
                        break;
                }
+
+               /* If types of arguments have to be checked */
+               if (reg_function->common.arg_info && reg_function->common.num_args) {
+                       int i;
+                       for (i = 0; i < reg_function->common.num_args; i++) {
+                               if (reg_function->common.arg_info[i].class_name ||
+                                   reg_function->common.arg_info[i].type_hint) {
+                                   reg_function->common.fn_flags |= ZEND_ACC_HAS_TYPE_HINTS;
+                                       break;
+                               }
+                       }
+               }
+
                if (scope) {
                        /* Look for ctor, dtor, clone
                         * If it's an old-style constructor, store it only if we don't have
index 23c5b22efdba2181169ba61828b0a3d174ba6ad6..5e284880e120372ad93e53d6a29094d00dc4323b 100644 (file)
@@ -212,6 +212,9 @@ typedef struct _zend_try_catch_element {
 #define ZEND_ACC_RETURN_REFERENCE              0x4000000
 #define ZEND_ACC_DONE_PASS_TWO                 0x8000000
 
+/* function has arguments with type hinting */
+#define ZEND_ACC_HAS_TYPE_HINTS                        0x10000000
+
 char *zend_visibility_string(zend_uint fn_flags);
 
 
index 45cfe909a32f8236faa41f377da6e89565a3797d..6eca6d01199ea6bcb5ec45ac247d459683177461 100644 (file)
@@ -1951,7 +1951,7 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY)
        LOAD_OPLINE();
 
        if (fbc->type == ZEND_INTERNAL_FUNCTION) {
-               if (fbc->common.arg_info) {
+               if (fbc->common.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) {
                        zend_uint i=0;
                        zval **p = (zval**)EX(function_state).arguments;
                        ulong arg_count = opline->extended_value;
index 107e460c8890b6e5784c8bcf54a3f4370df21a6c..dcb11836d6a3af08d11dcac5fbf021f293d5cd4a 100644 (file)
@@ -530,7 +530,7 @@ static int ZEND_FASTCALL zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_AR
        LOAD_OPLINE();
 
        if (fbc->type == ZEND_INTERNAL_FUNCTION) {
-               if (fbc->common.arg_info) {
+               if (fbc->common.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) {
                        zend_uint i=0;
                        zval **p = (zval**)EX(function_state).arguments;
                        ulong arg_count = opline->extended_value;