]> granicus.if.org Git - php/commitdiff
Support for class constants and static members for internal classes
authorDmitry Stogov <dmitry@php.net>
Thu, 1 Sep 2005 10:05:32 +0000 (10:05 +0000)
committerDmitry Stogov <dmitry@php.net>
Thu, 1 Sep 2005 10:05:32 +0000 (10:05 +0000)
NEWS
Zend/zend.h
Zend/zend_API.c
Zend/zend_API.h
Zend/zend_builtin_functions.c
Zend/zend_compile.c
Zend/zend_object_handlers.c
Zend/zend_opcode.c
Zend/zend_reflection_api.c
ext/reflection/php_reflection.c

diff --git a/NEWS b/NEWS
index d9f6998c7b9c3f4f7f03f8f495c62d24cdb0a0a0..66e0166e03e8115e9e07fe7599ada17f1775d3f2 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,8 @@
 PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? Aug 2005, PHP 5.1 Release Candidate 2
+- Implemented support for class constants and static members for internal
+  classes (Dmitry, Michael Wallner)
 - Upgraded bundled SQLite library for PDO:SQLite to 3.2.5 (Ilia)
 - Upgraded PCRE library to version 6.2. (Andrei)
 - Updated bundled libraries in Windows distribution. (Edin)
index d2aa70b6ed3bc88be187404eef24877e3992bde3..c242be7da143b289f107d91ff913716fd05e54fd 100644 (file)
@@ -331,6 +331,7 @@ struct _zend_class_entry {
        HashTable function_table;
        HashTable default_properties;
        HashTable properties_info;
+       HashTable default_static_members;
        HashTable *static_members;
        HashTable constants_table;
        struct _zend_function_entry *builtin_functions;
index d1704e6c5c4ed36acfe7f0df0807c8d7dd2a3c5d..8be11c71f796ac8a00dfd7b313d9b309e27bf0cb 100644 (file)
@@ -753,13 +753,53 @@ ZEND_API void zend_merge_properties(zval *obj, HashTable *properties, int destro
 
 ZEND_API void zend_update_class_constants(zend_class_entry *class_type TSRMLS_DC)
 {
-       if (!class_type->constants_updated) {
+       if (!class_type->constants_updated || !class_type->static_members) {
                zend_class_entry **scope = EG(in_execution)?&EG(scope):&CG(active_class_entry);
                zend_class_entry *old_scope = *scope;
 
                *scope = class_type;
                zend_hash_apply_with_argument(&class_type->default_properties, (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC);
+
+               if (!class_type->static_members) {
+                       HashPosition pos;
+                       zval **p;
+
+                       if (class_type->parent) {
+                               zend_update_class_constants(class_type->parent TSRMLS_CC);
+                       }
+                       ALLOC_HASHTABLE(class_type->static_members);
+                       zend_hash_init(class_type->static_members, 0, NULL, ZVAL_PTR_DTOR, 0);
+
+                       zend_hash_internal_pointer_reset_ex(&class_type->default_static_members, &pos);
+                       while (zend_hash_get_current_data_ex(&class_type->default_static_members, (void**)&p, &pos) == SUCCESS) {
+                               char *str_index;
+                               uint str_length;
+                               ulong num_index;
+                               zval **q;
+
+                               zend_hash_get_current_key_ex(&class_type->default_static_members, &str_index, &str_length, &num_index, 0, &pos);
+                               if ((*p)->is_ref &&
+                                   class_type->parent &&
+                                   zend_hash_find(&class_type->parent->default_static_members, str_index, str_length, (void**)&q) == SUCCESS &&
+                                   *p == *q &&
+                                   zend_hash_find(class_type->parent->static_members, str_index, str_length, (void**)&q) == SUCCESS) {
+                                       (*q)->refcount++;
+                                       (*q)->is_ref = 1;
+                                       zend_hash_add(class_type->static_members, str_index, str_length, (void**)q, sizeof(zval*), NULL);
+                               } else {
+                                       zval *q;
+                                       
+                                       ALLOC_ZVAL(q);
+                                       *q = **p;
+                                       INIT_PZVAL(q)
+                                       zval_copy_ctor(q);
+                                       zend_hash_add(class_type->static_members, str_index, str_length, (void**)&q, sizeof(zval*), NULL);
+                               }
+                               zend_hash_move_forward_ex(&class_type->default_static_members, &pos);
+                       }
+               }
                zend_hash_apply_with_argument(class_type->static_members, (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC);
+
                *scope = old_scope;
                class_type->constants_updated = 1;
        }
@@ -2126,7 +2166,7 @@ ZEND_API int zend_declare_property_ex(zend_class_entry *ce, char *name, int name
                access_type |= ZEND_ACC_PUBLIC;
        }
        if (access_type & ZEND_ACC_STATIC) {
-               target_symbol_table = ce->static_members;
+               target_symbol_table = &ce->default_static_members;
        } else {
                target_symbol_table = &ce->default_properties;
        }
@@ -2274,6 +2314,73 @@ ZEND_API int zend_declare_property_stringl(zend_class_entry *ce, char *name, int
        return zend_declare_property(ce, name, name_length, property, access_type TSRMLS_CC);
 }
 
+ZEND_API int zend_declare_class_constant(zend_class_entry *ce, char *name, size_t name_length, zval *value TSRMLS_DC)
+{
+       return zend_hash_update(&ce->constants_table, name, name_length+1, &value, sizeof(zval *), NULL);
+}
+
+ZEND_API int zend_declare_class_constant_long(zend_class_entry *ce, char *name, size_t name_length, long value TSRMLS_DC)
+{
+       zval *constant;
+
+       if (ce->type & ZEND_INTERNAL_CLASS) {
+               constant = malloc(sizeof(zval));
+       } else {
+               ALLOC_ZVAL(constant);
+       }
+       ZVAL_LONG(constant, value);
+       INIT_PZVAL(constant);
+       return zend_declare_class_constant(ce, name, name_length, constant TSRMLS_CC);
+}
+
+ZEND_API int zend_declare_class_constant_bool(zend_class_entry *ce, char *name, size_t name_length, zend_bool value TSRMLS_DC)
+{
+       zval *constant;
+
+       if (ce->type & ZEND_INTERNAL_CLASS) {
+               constant = malloc(sizeof(zval));
+       } else {
+               ALLOC_ZVAL(constant);
+       }
+       ZVAL_BOOL(constant, value);
+       INIT_PZVAL(constant);
+       return zend_declare_class_constant(ce, name, name_length, constant TSRMLS_CC);
+}
+
+ZEND_API int zend_declare_class_constant_double(zend_class_entry *ce, char *name, size_t name_length, double value TSRMLS_DC)
+{
+       zval *constant;
+
+       if (ce->type & ZEND_INTERNAL_CLASS) {
+               constant = malloc(sizeof(zval));
+       } else {
+               ALLOC_ZVAL(constant);
+       }
+       ZVAL_DOUBLE(constant, value);
+       INIT_PZVAL(constant);
+       return zend_declare_class_constant(ce, name, name_length, constant TSRMLS_CC);
+}
+
+ZEND_API int zend_declare_class_constant_stringl(zend_class_entry *ce, char *name, size_t name_length, char *value, size_t value_length TSRMLS_DC)
+{
+       zval *constant;
+
+       if (ce->type & ZEND_INTERNAL_CLASS) {
+               constant = malloc(sizeof(zval));
+               ZVAL_STRINGL(constant, zend_strndup(value, value_length), value_length, 0);
+       } else {
+               ALLOC_ZVAL(constant);
+               ZVAL_STRINGL(constant, value, value_length, 1);
+       }
+       INIT_PZVAL(constant);
+       return zend_declare_class_constant(ce, name, name_length, constant TSRMLS_CC);
+}
+
+ZEND_API int zend_declare_class_constant_string(zend_class_entry *ce, char *name, size_t name_length, char *value TSRMLS_DC)
+{
+       return zend_declare_class_constant_stringl(ce, name, name_length, value, strlen(value) TSRMLS_CC);
+}
+
 ZEND_API void zend_update_property(zend_class_entry *scope, zval *object, char *name, int name_length, zval *value TSRMLS_DC)
 {
        zval property;
@@ -2361,6 +2468,106 @@ ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zval *object
        zend_update_property(scope, object, name, name_length, tmp TSRMLS_CC);
 }
 
+ZEND_API int zend_update_static_property(zend_class_entry *scope, char *name, int name_length, zval *value TSRMLS_DC)
+{
+       zval **property;
+       zend_class_entry *old_scope = EG(scope);
+       
+       EG(scope) = scope;
+       property = zend_std_get_static_property(scope, name, name_length, 0 TSRMLS_CC);
+       EG(scope) = old_scope;
+       if (!property) {
+               return FAILURE;
+       } else {
+               if (*property != value) {
+                       if (PZVAL_IS_REF(*property)) {
+                               zval_dtor(*property);
+                               (*property)->type = value->type;
+                               (*property)->value = value->value;
+                               if (value->refcount > 0) {
+                                       zval_copy_ctor(*property);
+                               }
+                       } else {
+                               zval *garbage = *property;
+
+                               value->refcount++;
+                               if (PZVAL_IS_REF(value)) {
+                                       SEPARATE_ZVAL(&value);
+                               }
+                               *property = value;
+                               zval_ptr_dtor(&garbage);
+                       }
+               }
+               return SUCCESS;
+       }
+}
+
+ZEND_API int zend_update_static_property_null(zend_class_entry *scope, char *name, int name_length TSRMLS_DC)
+{
+       zval *tmp;
+
+       ALLOC_ZVAL(tmp);
+       tmp->is_ref = 0;
+       tmp->refcount = 0;
+       ZVAL_NULL(tmp);
+       return zend_update_static_property(scope, name, name_length, tmp TSRMLS_CC);
+}
+
+ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, char *name, int name_length, long value TSRMLS_DC)
+{
+       zval *tmp;
+       
+       ALLOC_ZVAL(tmp);
+       tmp->is_ref = 0;
+       tmp->refcount = 0;
+       ZVAL_BOOL(tmp, value);
+       return zend_update_static_property(scope, name, name_length, tmp TSRMLS_CC);
+}
+
+ZEND_API int zend_update_static_property_long(zend_class_entry *scope, char *name, int name_length, long value TSRMLS_DC)
+{
+       zval *tmp;
+       
+       ALLOC_ZVAL(tmp);
+       tmp->is_ref = 0;
+       tmp->refcount = 0;
+       ZVAL_LONG(tmp, value);
+       return zend_update_static_property(scope, name, name_length, tmp TSRMLS_CC);
+}
+
+ZEND_API int zend_update_static_property_double(zend_class_entry *scope, char *name, int name_length, double value TSRMLS_DC)
+{
+       zval *tmp;
+       
+       ALLOC_ZVAL(tmp);
+       tmp->is_ref = 0;
+       tmp->refcount = 0;
+       ZVAL_DOUBLE(tmp, value);
+       return zend_update_static_property(scope, name, name_length, tmp TSRMLS_CC);
+}
+
+ZEND_API int zend_update_static_property_string(zend_class_entry *scope, char *name, int name_length, char *value TSRMLS_DC)
+{
+       zval *tmp;
+       
+       ALLOC_ZVAL(tmp);
+       tmp->is_ref = 0;
+       tmp->refcount = 0;
+       ZVAL_STRING(tmp, value, 1);
+       return zend_update_static_property(scope, name, name_length, tmp TSRMLS_CC);
+}
+
+ZEND_API int zend_update_static_property_stringl(zend_class_entry *scope, char *name, int name_length, char *value, int value_len TSRMLS_DC)
+{
+       zval *tmp;
+       
+       ALLOC_ZVAL(tmp);
+       tmp->is_ref = 0;
+       tmp->refcount = 0;
+       ZVAL_STRINGL(tmp, value, value_len, 1);
+       return zend_update_static_property(scope, name, name_length, tmp TSRMLS_CC);
+}
+
 ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, char *name, int name_length, zend_bool silent TSRMLS_DC)
 {
        zval property, *value;
@@ -2382,6 +2589,18 @@ ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, char *n
        return value;
 }
 
+ZEND_API zval *zend_read_static_property(zend_class_entry *scope, char *name, int name_length, zend_bool silent TSRMLS_DC)
+{
+       zval **property;
+       zend_class_entry *old_scope = EG(scope);
+       
+       EG(scope) = scope;
+       property = zend_std_get_static_property(scope, name, name_length, silent TSRMLS_CC);
+       EG(scope) = old_scope;
+
+       return property?*property:NULL;
+}
+
 /*
  * Local variables:
  * tab-width: 4
index d42c91451267605e73eb142b79a912bac50d78cd..6ac16441ba83e24217e671d68ff7f30dc62fb86a 100644 (file)
@@ -212,6 +212,13 @@ ZEND_API int zend_declare_property_double(zend_class_entry *ce, char *name, int
 ZEND_API int zend_declare_property_string(zend_class_entry *ce, char *name, int name_length, char *value, int access_type TSRMLS_DC);
 ZEND_API int zend_declare_property_stringl(zend_class_entry *ce, char *name, int name_length, char *value, int value_len, int access_type TSRMLS_DC);
 
+ZEND_API int zend_declare_class_constant(zend_class_entry *ce, char *name, size_t name_length, zval *value TSRMLS_DC);
+ZEND_API int zend_declare_class_constant_long(zend_class_entry *ce, char *name, size_t name_length, long value TSRMLS_DC);
+ZEND_API int zend_declare_class_constant_bool(zend_class_entry *ce, char *name, size_t name_length, zend_bool value TSRMLS_DC);
+ZEND_API int zend_declare_class_constant_double(zend_class_entry *ce, char *name, size_t name_length, double value TSRMLS_DC);
+ZEND_API int zend_declare_class_constant_stringl(zend_class_entry *ce, char *name, size_t name_length, char *value, size_t value_length TSRMLS_DC);
+ZEND_API int zend_declare_class_constant_string(zend_class_entry *ce, char *name, size_t name_length, char *value TSRMLS_DC);
+
 ZEND_API void zend_update_class_constants(zend_class_entry *class_type TSRMLS_DC);
 ZEND_API void zend_update_property(zend_class_entry *scope, zval *object, char *name, int name_length, zval *value TSRMLS_DC);
 ZEND_API void zend_update_property_null(zend_class_entry *scope, zval *object, char *name, int name_length TSRMLS_DC);
@@ -221,8 +228,18 @@ ZEND_API void zend_update_property_double(zend_class_entry *scope, zval *object,
 ZEND_API void zend_update_property_string(zend_class_entry *scope, zval *object, char *name, int name_length, char *value TSRMLS_DC);
 ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zval *object, char *name, int name_length, char *value, int value_length TSRMLS_DC);
 
+ZEND_API int zend_update_static_property(zend_class_entry *scope, char *name, int name_length, zval *value TSRMLS_DC);
+ZEND_API int zend_update_static_property_null(zend_class_entry *scope, char *name, int name_length TSRMLS_DC);
+ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, char *name, int name_length, long value TSRMLS_DC);
+ZEND_API int zend_update_static_property_long(zend_class_entry *scope, char *name, int name_length, long value TSRMLS_DC);
+ZEND_API int zend_update_static_property_double(zend_class_entry *scope, char *name, int name_length, double value TSRMLS_DC);
+ZEND_API int zend_update_static_property_string(zend_class_entry *scope, char *name, int name_length, char *value TSRMLS_DC);
+ZEND_API int zend_update_static_property_stringl(zend_class_entry *scope, char *name, int name_length, char *value, int value_length TSRMLS_DC);
+
 ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, char *name, int name_length, zend_bool silent TSRMLS_DC);
 
+ZEND_API zval *zend_read_static_property(zend_class_entry *scope, char *name, int name_length, zend_bool silent TSRMLS_DC);
+
 ZEND_API zend_class_entry *zend_get_class_entry(zval *zobject TSRMLS_DC);
 ZEND_API int zend_get_object_classname(zval *object, char **class_name, zend_uint *class_name_len TSRMLS_DC);
 
index 39bbab297288224b81054246ce9369396043c7ca..e46a9ef0a978530528e55402f1629baf3ebfc3a3 100644 (file)
@@ -737,6 +737,7 @@ ZEND_FUNCTION(get_class_vars)
        } else {
                array_init(return_value);
                add_class_vars(*pce, &(*pce)->default_properties, return_value TSRMLS_CC);
+               zend_update_class_constants(*pce TSRMLS_CC);
                add_class_vars(*pce, (*pce)->static_members, return_value TSRMLS_CC);
        }
 }
index 0ab89a476619f79cfdf60ecc63c74a8ebf0fa612..ec1df4b844964e26538c1d51809c7af2dd2ada2a 100644 (file)
@@ -2039,9 +2039,17 @@ static zend_bool do_inherit_property_access_check(HashTable *target_ht, zend_pro
                        zend_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) {
                                zval **prop;
-                               if (zend_hash_find(parent_ce->static_members, prot_name, prot_name_length+1, (void**)&prop) == SUCCESS) {
+                               HashTable *ht;
+
+                               if (parent_ce->type != ce->type) {
+                                       /* User class extends internal class */
+                                       ht = parent_ce->static_members;
+                               } else {
+                                       ht = &parent_ce->default_static_members;
+                               }
+                               if (zend_hash_find(ht, prot_name, prot_name_length+1, (void**)&prop) == SUCCESS) {
                                        zval **new_prop;
-                                       if (zend_hash_find(ce->static_members, child_info->name, child_info->name_length+1, (void**)&new_prop) == SUCCESS) {
+                                       if (zend_hash_find(ht, child_info->name, child_info->name_length+1, (void**)&new_prop) == SUCCESS) {
                                                if (Z_TYPE_PP(new_prop) != IS_NULL && Z_TYPE_PP(prop) != IS_NULL) {
                                                        char *prop_name, *tmp;
                                                        zend_unmangle_property_name(child_info->name, &tmp, &prop_name);
@@ -2051,8 +2059,8 @@ static zend_bool do_inherit_property_access_check(HashTable *target_ht, zend_pro
                                                }
                                        }
                                        (*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);
+                                       zend_hash_update(&ce->default_static_members, child_info->name, child_info->name_length+1, (void**)prop, sizeof(zval*), NULL);
+                                       zend_hash_del(&ce->default_static_members, prot_name, prot_name_length+1);
                                }
                        } else {
                                zend_hash_del(&ce->default_properties, prot_name, prot_name_length+1);
@@ -2138,7 +2146,13 @@ ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent
 
        /* 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_static_prop, NULL, sizeof(zval *), 0);
+       if (parent_ce->type != ce->type) {
+               /* User class extends internal class */
+               zend_update_class_constants(parent_ce  TSRMLS_CC);
+               zend_hash_merge(&ce->default_static_members, parent_ce->static_members, (void (*)(void *)) inherit_static_prop, NULL, sizeof(zval *), 0);
+       } else {
+               zend_hash_merge(&ce->default_static_members, &parent_ce->default_static_members, (void (*)(void *)) inherit_static_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);
 
        zend_hash_merge(&ce->constants_table, &parent_ce->constants_table, (void (*)(void *)) zval_add_ref, NULL, sizeof(zval *), 0);
@@ -2268,7 +2282,7 @@ ZEND_API zend_class_entry *do_bind_inherited_class(zend_op *opline, HashTable *c
                zend_hash_destroy(&ce->function_table);
                zend_hash_destroy(&ce->default_properties);
                zend_hash_destroy(&ce->properties_info);
-               zend_hash_destroy(ce->static_members);
+               zend_hash_destroy(&ce->default_static_members);
                zend_hash_destroy(&ce->constants_table);
                return NULL;
        }
@@ -3932,17 +3946,12 @@ ZEND_API void zend_initialize_class_data(zend_class_entry *ce, zend_bool nullify
 
        zend_hash_init_ex(&ce->default_properties, 0, NULL, zval_ptr_dtor_func, persistent_hashes, 0);
        zend_hash_init_ex(&ce->properties_info, 0, NULL, (dtor_func_t) (persistent_hashes ? zend_destroy_property_info_internal : zend_destroy_property_info), persistent_hashes, 0);
-
-       if (persistent_hashes) {
-               ce->static_members = (HashTable *) malloc(sizeof(HashTable));
-       } else {
-               ALLOC_HASHTABLE(ce->static_members);
-       }
-
-       zend_hash_init_ex(ce->static_members, 0, NULL, zval_ptr_dtor_func, persistent_hashes, 0);
+       zend_hash_init_ex(&ce->default_static_members, 0, NULL, zval_ptr_dtor_func, persistent_hashes, 0);
        zend_hash_init_ex(&ce->constants_table, 0, NULL, zval_ptr_dtor_func, persistent_hashes, 0);
        zend_hash_init_ex(&ce->function_table, 0, NULL, ZEND_FUNCTION_DTOR, persistent_hashes, 0);
 
+       ce->static_members = (ce->type == ZEND_INTERNAL_CLASS) ? NULL : &ce->default_static_members;
+
        if (nullify_handlers) {
                ce->constructor = NULL;
                ce->destructor = NULL;
index 6f385c1b51d63cab6dce82033e7331f666c5b1cf..89cf73686a846e3a80558f68ddd3a6c3c6f912c1 100644 (file)
@@ -820,6 +820,8 @@ ZEND_API zval **zend_std_get_static_property(zend_class_entry *ce, char *propert
                return NULL;
        }
 
+       zend_update_class_constants(tmp_ce TSRMLS_CC);
+
        zend_hash_quick_find(tmp_ce->static_members, property_info->name, property_info->name_length+1, property_info->h, (void **) &retval);
 
        if (!retval) {
@@ -830,7 +832,6 @@ ZEND_API zval **zend_std_get_static_property(zend_class_entry *ce, char *propert
                }
        }
        
-       zval_update_constant(retval, (void *) 1 TSRMLS_CC);
        return retval;
 }
 
index 37bb6b604a1d2344dbb4947fc169b25124798e8f..9b305b25e29df2cfec789326fbc43ffe28dd6a19 100644 (file)
@@ -138,11 +138,17 @@ ZEND_API int zend_cleanup_function_data(zend_function *function TSRMLS_DC)
 
 ZEND_API int zend_cleanup_class_data(zend_class_entry **pce TSRMLS_DC)
 {
+       if ((*pce)->static_members) {
+               if ((*pce)->static_members != &(*pce)->default_static_members) {
+                       zend_hash_destroy((*pce)->static_members);
+                       FREE_HASHTABLE((*pce)->static_members);
+               }
+               (*pce)->static_members = NULL;
+       }
        if ((*pce)->type == ZEND_USER_CLASS) {
                /* Clean all parts that can contain run-time data */
                /* Note that only run-time accessed data need to be cleaned up, pre-defined data can
                   not contain objects and thus are not probelmatic */
-               zend_hash_clean((*pce)->static_members);
                zend_hash_apply(&(*pce)->function_table, (apply_func_t) zend_cleanup_function_data TSRMLS_CC);
        }
        return 0;
@@ -159,10 +165,9 @@ ZEND_API void destroy_zend_class(zend_class_entry **pce)
                case ZEND_USER_CLASS:
                        zend_hash_destroy(&ce->default_properties);
                        zend_hash_destroy(&ce->properties_info);
-                       zend_hash_destroy(ce->static_members);
+                       zend_hash_destroy(&ce->default_static_members);
                        efree(ce->name);
                        zend_hash_destroy(&ce->function_table);
-                       FREE_HASHTABLE(ce->static_members);
                        zend_hash_destroy(&ce->constants_table);
                        if (ce->num_interfaces > 0 && ce->interfaces) {
                                efree(ce->interfaces);
@@ -175,10 +180,9 @@ ZEND_API void destroy_zend_class(zend_class_entry **pce)
                case ZEND_INTERNAL_CLASS:
                        zend_hash_destroy(&ce->default_properties);
                        zend_hash_destroy(&ce->properties_info);
-                       zend_hash_destroy(ce->static_members);
+                       zend_hash_destroy(&ce->default_static_members);
                        free(ce->name);
                        zend_hash_destroy(&ce->function_table);
-                       free(ce->static_members);
                        zend_hash_destroy(&ce->constants_table);
                        if (ce->num_interfaces > 0) {
                                free(ce->interfaces);
index e741f96cf173a03d56af8f33b2577adab5023662..14d0c55d1233f2f4a91a3fa2c05132123d3dfbfd 100644 (file)
@@ -3480,6 +3480,7 @@ ZEND_METHOD(reflection_property, setValue)
                                return;
                        }
                }
+               zend_update_class_constants(intern->ce TSRMLS_CC);
                prop_table = intern->ce->static_members;
        } else {
                if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "oz", &object, &value) == FAILURE) {
index e741f96cf173a03d56af8f33b2577adab5023662..14d0c55d1233f2f4a91a3fa2c05132123d3dfbfd 100644 (file)
@@ -3480,6 +3480,7 @@ ZEND_METHOD(reflection_property, setValue)
                                return;
                        }
                }
+               zend_update_class_constants(intern->ce TSRMLS_CC);
                prop_table = intern->ce->static_members;
        } else {
                if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "oz", &object, &value) == FAILURE) {