]> granicus.if.org Git - php/commitdiff
- Rename compatiblity mode to zend.ze2_compatibility_mode (it doesn't only affect...
authorZeev Suraski <zeev@php.net>
Wed, 25 Feb 2004 10:57:10 +0000 (10:57 +0000)
committerZeev Suraski <zeev@php.net>
Wed, 25 Feb 2004 10:57:10 +0000 (10:57 +0000)
- Perform implementation checks even with simple inheritance (off when
  compatibility mode is enabled).
- Restore default arguments in interfaces and handle it correctly.
- Move registration of internal classes later in the startup sequence
  in order to have INI options available.

Zend/zend.c
Zend/zend_compile.c
Zend/zend_execute.c
Zend/zend_execute_API.c
Zend/zend_globals.h
Zend/zend_variables.c

index 8005076a4eb320d34e3b1fa9134fe418b8e3fbf1..316abaec9f26c338cbe3fbd9ac48d6b46498e365 100644 (file)
@@ -73,20 +73,9 @@ static ZEND_INI_MH(OnUpdateErrorReporting)
 }
 
 
-static ZEND_INI_MH(OnUpdateImplicitClone)
-{
-       if (!new_value) {
-               EG(implicit_clone) = 0;
-       } else {
-               EG(implicit_clone) = atoi(new_value) ? 1 : 0;
-       }
-       return SUCCESS;
-}
-
-
 ZEND_INI_BEGIN()
-       ZEND_INI_ENTRY("error_reporting",                       NULL,           ZEND_INI_ALL,           OnUpdateErrorReporting)
-       ZEND_INI_ENTRY("zend2.implicit_clone",          NULL,           ZEND_INI_ALL,           OnUpdateImplicitClone)
+       ZEND_INI_ENTRY("error_reporting",                               NULL,           ZEND_INI_ALL,           OnUpdateErrorReporting)
+       STD_ZEND_INI_BOOLEAN("zend.ze1_compatibility_mode",     "0",    ZEND_INI_ALL,           OnUpdateBool,   ze1_compatibility_mode, zend_executor_globals,  executor_globals)
 ZEND_INI_END()
 
 
@@ -643,7 +632,6 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions, i
        if (start_builtin_functions) {
                zend_startup_builtin_functions(TSRMLS_C);
        }
-       zend_register_default_classes(TSRMLS_C);
 
        zend_ini_startup(TSRMLS_C);
 
index 1826221dfcb4a435ee52c7c79d4383ac9005fb6d..7407429223eed5c15e9d9706565202f7d4f92959 100644 (file)
@@ -1136,11 +1136,6 @@ void zend_do_receive_arg(zend_uchar op, znode *var, znode *offset, znode *initia
        opline->result = *var;
        opline->op1 = *offset;
        if (op == ZEND_RECV_INIT) {
-               if ((CG(active_class_entry) && CG(active_class_entry)->ce_flags & ZEND_ACC_INTERFACE)
-                       || CG(active_op_array)->fn_flags & ZEND_ACC_ABSTRACT) {
-                       CG(active_op_array)->num_args--; /* invalidate the current arg_info entry */
-                       zend_error(E_COMPILE_ERROR, "Abstract methods cannot have default values for arguments");
-               }
                opline->op2 = *initialization;
        } else {
                CG(active_op_array)->required_num_args = CG(active_op_array)->num_args;
@@ -1723,7 +1718,7 @@ static zend_bool zend_do_perform_implementation_check(zend_function *fe)
        }
 
        /* check number of arguments */
-       if (proto->common.num_args < fe->common.required_num_args
+       if (proto->common.required_num_args != fe->common.required_num_args
                || proto->common.num_args > fe->common.num_args) {
                return 0;
        }
@@ -1768,6 +1763,7 @@ static zend_bool do_inherit_method_check(HashTable *child_function_table, zend_f
        zend_uint child_flags;
        zend_uint parent_flags = parent->common.fn_flags;
        zend_function *child;
+       TSRMLS_FETCH();
 
        if (zend_hash_quick_find(child_function_table, hash_key->arKey, hash_key->nKeyLength, hash_key->h, (void **) &child)==FAILURE) {
                if (parent_flags & ZEND_ACC_ABSTRACT) {
@@ -1818,15 +1814,22 @@ static zend_bool do_inherit_method_check(HashTable *child_function_table, zend_f
                }
        }
 
-       if (parent_flags & ZEND_ACC_ABSTRACT) {
+       if (EG(ze1_compatibility_mode)) {
+               if (parent_flags & ZEND_ACC_ABSTRACT) {
+                       child->common.prototype = parent;
+                       child->common.fn_flags |= ZEND_ACC_IMPLEMENTED_ABSTRACT;
+               } else {
+                       child->common.prototype = parent->common.prototype;
+               }
+       } else {
                child->common.prototype = parent;
-               child->common.fn_flags |= ZEND_ACC_IMPLEMENTED_ABSTRACT;
-       } else if (parent->common.prototype) {
-               child->common.prototype = parent->common.prototype;
+               if (parent_flags & ZEND_ACC_ABSTRACT) {
+                       child->common.fn_flags |= ZEND_ACC_IMPLEMENTED_ABSTRACT;
+               }
        }
 
        if (!zend_do_perform_implementation_check(child)) {
-               zend_error(E_COMPILE_ERROR, "Declaration of %s::%s() must be the same as %s::%s()", ZEND_FN_SCOPE_NAME(child), child->common.function_name, ZEND_FN_SCOPE_NAME(child->common.prototype), child->common.prototype->common.function_name);
+               zend_error(E_COMPILE_ERROR, "Declaration of %s::%s() must be compatible with that of %s::%s()", ZEND_FN_SCOPE_NAME(child), child->common.function_name, ZEND_FN_SCOPE_NAME(child->common.prototype), child->common.prototype->common.function_name);
        }
 
        return 0;
index 3f29e2389aa61f5afa49c72c5906f4475803a761..b45a7a1cf335490de31308b69bdfea4db4679d51 100644 (file)
@@ -382,7 +382,7 @@ static inline void zend_assign_to_object(znode *result, zval **object_ptr, znode
        }
        
        /* here we are sure we are dealing with an object */
-       if (EG(implicit_clone)) {
+       if (EG(ze1_compatibility_mode)) {
                SEPARATE_ZVAL_IF_NOT_REF(object_ptr);
                object = *object_ptr;
        }
@@ -2401,7 +2401,7 @@ int zend_init_ctor_call_handler(ZEND_OPCODE_HANDLER_ARGS)
 
        /* We are not handling overloaded classes right now */
        EX(object) = get_zval_ptr(&opline->op1, EX(Ts), &EG(free_op1), BP_VAR_R);
-       if (!PZVAL_IS_REF(EX(object)) || !EG(implicit_clone)) {
+       if (!PZVAL_IS_REF(EX(object)) || !EG(ze1_compatibility_mode)) {
                EX(object)->refcount++; /* For $this pointer */
        } else {
                zval *this_ptr;
@@ -2459,7 +2459,7 @@ int zend_init_method_call_handler(ZEND_OPCODE_HANDLER_ARGS)
        if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) {
                EX(object) = NULL;
        } else {
-               if (!PZVAL_IS_REF(EX(object)) || !EG(implicit_clone)) {
+               if (!PZVAL_IS_REF(EX(object)) || !EG(ze1_compatibility_mode)) {
                        EX(object)->refcount++; /* For $this pointer */
                } else {
                        zval *this_ptr;
index 37ec49417ac23a0bb1f1aa598fe68db453a0c6c0..b9ae38b096e92ee23e1081daccc194c1044c6b52 100644 (file)
@@ -132,7 +132,6 @@ void init_executor(TSRMLS_D)
        EG(symtable_cache_ptr) = EG(symtable_cache)-1;
        EG(symtable_cache_limit)=EG(symtable_cache)+SYMTABLE_CACHE_SIZE-1;
        EG(no_extensions)=0;
-       EG(implicit_clone)=0;
 
        EG(function_table) = CG(function_table);
        EG(class_table) = CG(class_table);
index 34f74a567cd9e12a9c6dc7c49629bb0779251982..ae38ffb7db910280dd4b7ad7b673c989b3e32d8f 100644 (file)
@@ -193,7 +193,7 @@ struct _zend_executor_globals {
        zend_bool in_autoload;
        zend_bool bailout_set;
        zend_bool full_tables_cleanup;
-       zend_bool implicit_clone;
+       zend_bool ze1_compatibility_mode;
 
        /* for extended information support */
        zend_bool no_extensions;
index 8f60fcffd95a16750399eb8271565a55aa4f11a8..e14d0c96b3013027d012d72a6eaa516b0d1abdac 100644 (file)
@@ -154,7 +154,7 @@ ZEND_API int _zval_copy_ctor(zval *zvalue ZEND_FILE_LINE_DC)
                        {
                                TSRMLS_FETCH();
 
-                               if (EG(implicit_clone)) {
+                               if (EG(ze1_compatibility_mode)) {
                                        zvalue->value.obj = zvalue->value.obj.handlers->clone_obj(zvalue TSRMLS_CC);
                                } else {
                                        Z_OBJ_HT_P(zvalue)->add_ref(zvalue TSRMLS_CC);