]> granicus.if.org Git - php/commitdiff
Fix static properties.
authorMarcus Boerger <helly@php.net>
Wed, 3 Sep 2003 16:13:40 +0000 (16:13 +0000)
committerMarcus Boerger <helly@php.net>
Wed, 3 Sep 2003 16:13:40 +0000 (16:13 +0000)
#
# There's only an errormessage missing which i'll wommit as soon as i find out
# how to do it best. But besides that damn message everything works now and all
# inheritance rules apply.
#

Zend/zend_API.c
Zend/zend_compile.c
Zend/zend_execute.c
Zend/zend_object_handlers.c

index 4b3c938ff27df509976136bf4d8fafb9952b8626..fdb2d6899a970104f3e0fd58143e183a92da25c5 100644 (file)
@@ -700,7 +700,6 @@ ZEND_API int _object_and_properties_init(zval *arg, zend_class_entry *class_type
 
        if (!class_type->constants_updated) {
                zend_hash_apply_with_argument(&class_type->default_properties, (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC);
-               zend_hash_apply_with_argument(class_type->static_members, (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC);
                class_type->constants_updated = 1;
        }
        
index 122d64a7d17c795ae31d77f06763779af9f3842d..988aa00c8d53a0746a957189d456be91edd121f5 100644 (file)
@@ -1768,7 +1768,12 @@ static zend_bool do_inherit_property_access_check(HashTable *target_ht, zend_pro
 
                        mangle_property_name(&prot_name, &prot_name_length, "*", 1, child_info->name, child_info->name_length, ce->type & ZEND_INTERNAL_CLASS);
                        if (child_info->flags & ZEND_ACC_STATIC) {
-                               zend_hash_del(ce->static_members, prot_name, prot_name_length+1);
+                               zval **prop;
+                               if (zend_hash_find(parent_ce->static_members, prot_name, prot_name_length+1, (void**)&prop) == SUCCESS) {
+                                       (*prop)->refcount++;
+                                       zend_hash_update(ce->static_members, child_info->name, child_info->name_length+1, (void**)prop, sizeof(zval*), NULL);
+                                       zend_hash_del(ce->static_members, prot_name, prot_name_length+1);
+                               }
                        } else {
                                zend_hash_del(&ce->default_properties, prot_name, prot_name_length+1);
                        }
@@ -1797,6 +1802,13 @@ ZEND_API void zend_do_inherit_interfaces(zend_class_entry *ce, zend_class_entry
 }
 
 
+static void inherit_sttaic_prop(zval **p)
+{
+       (*p)->refcount++;
+       (*p)->is_ref = 1;
+}
+
+
 void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent_ce)
 {
        if ((ce->ce_flags & ZEND_ACC_INTERFACE)
@@ -1813,10 +1825,9 @@ void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent_ce)
 
        /* Inherit properties */
        zend_hash_merge(&ce->default_properties, &parent_ce->default_properties, (void (*)(void *)) zval_add_ref, NULL, sizeof(zval *), 0);
+       zend_hash_merge(ce->static_members, parent_ce->static_members, (void (*)(void *)) inherit_sttaic_prop, NULL, sizeof(zval *), 0);
        zend_hash_merge_ex(&ce->properties_info, &parent_ce->properties_info, (copy_ctor_func_t) (ce->type & ZEND_INTERNAL_CLASS ? zend_duplicate_property_info_internal : zend_duplicate_property_info), sizeof(zend_property_info), (merge_checker_func_t) do_inherit_property_access_check, ce);
 
-       /* STATIC_MEMBERS_FIXME */
-/*     zend_hash_merge(ce->static_members, parent_ce->static_members, (void (*)(void *)) zval_add_ref, (void *) &tmp, sizeof(zval *), 0); */
        zend_hash_merge(&ce->constants_table, &parent_ce->constants_table, (void (*)(void *)) zval_add_ref, NULL, sizeof(zval *), 0);
        zend_hash_merge_ex(&ce->function_table, &parent_ce->function_table, (copy_ctor_func_t) do_inherit_method, sizeof(zend_function), (merge_checker_func_t) do_inherit_method_check, ce);
        do_inherit_parent_constructor(ce);
index de31c1c89c4117bf4c25fe336e8de7372c9064a7..c7eccbf33b6cd3a8640d963136ae6abd085ec94f 100644 (file)
@@ -722,7 +722,6 @@ static void zend_fetch_var_address(zend_op *opline, temp_variable *Ts, int type
                                FREE_OP(Ts, &opline->op1, free_op1);
                                break;
                        case ZEND_FETCH_STATIC:
-                               zval_update_constant(retval, (void *) 1 TSRMLS_CC);
                                break;
                }
        }
index a5914cbad9d2b5282cea9ac65c3e81cb2476dd1f..3892918bf598d25b7b8af6c9a2bd3c5e6432b2b1 100644 (file)
@@ -726,12 +726,7 @@ zval **zend_std_get_static_property(zend_class_entry *ce, char *property_name, i
                zend_error(E_ERROR, "Cannot access %s property %s::$%s", zend_visibility_string(property_info->flags), ce->name, property_name);
        }
 
-       while (tmp_ce) {
-               if (zend_hash_quick_find(tmp_ce->static_members, property_info->name, property_info->name_length+1, property_info->h, (void **) &retval)==SUCCESS) {
-                       break;
-               }
-               tmp_ce = tmp_ce->parent;
-       }
+       zend_hash_quick_find(tmp_ce->static_members, property_info->name, property_info->name_length+1, property_info->h, (void **) &retval);
 
        if (!retval) {
                if (silent) {
@@ -741,7 +736,6 @@ zval **zend_std_get_static_property(zend_class_entry *ce, char *property_name, i
                }
        }
        
-       zval_update_constant(retval, (void *) 1 TSRMLS_CC);
        return retval;
 }