mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Rework static class properties - now supports access restrictions
This commit is contained in:
parent
376d63170b
commit
17439aa9c4
8 changed files with 127 additions and 87 deletions
|
@ -378,7 +378,7 @@ static void register_standard_class(void)
|
|||
zend_standard_class_def->name = zend_strndup("stdClass", zend_standard_class_def->name_length);
|
||||
zend_standard_class_def->parent = NULL;
|
||||
zend_hash_init_ex(&zend_standard_class_def->default_properties, 0, NULL, ZVAL_PTR_DTOR, 1, 0);
|
||||
zend_hash_init_ex(&zend_standard_class_def->default_properties_info, 0, NULL, (dtor_func_t) zend_destroy_property_info, 1, 0);
|
||||
zend_hash_init_ex(&zend_standard_class_def->properties_info, 0, NULL, (dtor_func_t) zend_destroy_property_info, 1, 0);
|
||||
zend_standard_class_def->static_members = (HashTable *) malloc(sizeof(HashTable));
|
||||
zend_hash_init_ex(zend_standard_class_def->static_members, 0, NULL, ZVAL_PTR_DTOR, 1, 0);
|
||||
zend_hash_init_ex(&zend_standard_class_def->constants_table, 0, NULL, ZVAL_PTR_DTOR, 1, 0);
|
||||
|
|
|
@ -303,7 +303,7 @@ struct _zend_class_entry {
|
|||
|
||||
HashTable function_table;
|
||||
HashTable default_properties;
|
||||
HashTable default_properties_info;
|
||||
HashTable properties_info;
|
||||
HashTable class_table;
|
||||
HashTable *static_members;
|
||||
HashTable constants_table;
|
||||
|
|
|
@ -1379,7 +1379,7 @@ ZEND_API zend_class_entry *zend_register_internal_class(zend_class_entry *orig_c
|
|||
class_entry->constants_updated = 0;
|
||||
class_entry->ce_flags = 0;
|
||||
zend_hash_init(&class_entry->default_properties, 0, NULL, ZVAL_PTR_DTOR, 1);
|
||||
zend_hash_init(&class_entry->default_properties_info, 0, NULL, NULL, 1);
|
||||
zend_hash_init(&class_entry->properties_info, 0, NULL, NULL, 1);
|
||||
class_entry->static_members = (HashTable *) malloc(sizeof(HashTable));
|
||||
zend_hash_init(class_entry->static_members, 0, NULL, ZVAL_PTR_DTOR, 1);
|
||||
zend_hash_init(&class_entry->constants_table, 0, NULL, ZVAL_PTR_DTOR, 1);
|
||||
|
|
|
@ -1616,7 +1616,7 @@ static zend_bool do_inherit_property_access_check(HashTable *target_ht, zend_pro
|
|||
return 0; /* don't copy access information to child */
|
||||
}
|
||||
|
||||
if (zend_hash_quick_find(&ce->default_properties_info, hash_key->arKey, hash_key->nKeyLength, hash_key->h, (void **) &child_info)==SUCCESS) {
|
||||
if (zend_hash_quick_find(&ce->properties_info, hash_key->arKey, hash_key->nKeyLength, hash_key->h, (void **) &child_info)==SUCCESS) {
|
||||
if ((child_info->flags & ZEND_ACC_PPP_MASK) > (parent_info->flags & ZEND_ACC_PPP_MASK)) {
|
||||
zend_error(E_COMPILE_ERROR, "Access level to %s::$%s must be %s (as in class %s)%s", ce->name, hash_key->arKey, zend_visibility_string(parent_info->flags), parent_ce->name, (parent_info->flags&ZEND_ACC_PUBLIC) ? "" : " or weaker");
|
||||
}
|
||||
|
@ -1633,7 +1633,7 @@ 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_ex(&ce->default_properties_info, &parent_ce->default_properties_info, (copy_ctor_func_t) zend_duplicate_property_info, sizeof(zend_property_info), (merge_checker_func_t) do_inherit_property_access_check, ce);
|
||||
zend_hash_merge_ex(&ce->properties_info, &parent_ce->properties_info, (copy_ctor_func_t) 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); */
|
||||
|
@ -1660,7 +1660,7 @@ static void create_class(HashTable *class_table, char *name, int name_length, ze
|
|||
zend_hash_init(&new_class_entry->function_table, 10, NULL, ZEND_FUNCTION_DTOR, 0);
|
||||
zend_hash_init(&new_class_entry->class_table, 10, NULL, ZEND_CLASS_DTOR, 0);
|
||||
zend_hash_init(&new_class_entry->default_properties, 10, NULL, ZVAL_PTR_DTOR, 0);
|
||||
zend_hash_init(&new_class_entry->default_properties_info, 10, NULL, NULL, 0);
|
||||
zend_hash_init(&new_class_entry->properties_info, 10, NULL, NULL, 0);
|
||||
ALLOC_HASHTABLE(new_class_entry->static_members);
|
||||
zend_hash_init(new_class_entry->static_members, 10, NULL, ZVAL_PTR_DTOR, 0);
|
||||
zend_hash_init(&new_class_entry->constants_table, 10, NULL, ZVAL_PTR_DTOR, 0);
|
||||
|
@ -1804,7 +1804,7 @@ ZEND_API int do_bind_inherited_class(zend_op *opline, HashTable *function_table,
|
|||
ce->refcount--;
|
||||
zend_hash_destroy(&ce->function_table);
|
||||
zend_hash_destroy(&ce->default_properties);
|
||||
zend_hash_destroy(&ce->default_properties_info);
|
||||
zend_hash_destroy(&ce->properties_info);
|
||||
zend_hash_destroy(ce->static_members);
|
||||
zend_hash_destroy(&ce->constants_table);
|
||||
return FAILURE;
|
||||
|
@ -2140,7 +2140,7 @@ void zend_do_begin_class_declaration(znode *class_token, znode *class_name, znod
|
|||
zend_hash_init(&new_class_entry->function_table, 10, NULL, ZEND_FUNCTION_DTOR, 0);
|
||||
zend_hash_init(&new_class_entry->class_table, 10, NULL, ZEND_CLASS_DTOR, 0);
|
||||
zend_hash_init(&new_class_entry->default_properties, 10, NULL, ZVAL_PTR_DTOR, 0);
|
||||
zend_hash_init(&new_class_entry->default_properties_info, 10, NULL, NULL, 0);
|
||||
zend_hash_init(&new_class_entry->properties_info, 10, NULL, NULL, 0);
|
||||
ALLOC_HASHTABLE(new_class_entry->static_members);
|
||||
zend_hash_init(new_class_entry->static_members, 10, NULL, ZVAL_PTR_DTOR, 0);
|
||||
zend_hash_init(&new_class_entry->constants_table, 10, NULL, ZVAL_PTR_DTOR, 0);
|
||||
|
@ -2213,6 +2213,7 @@ void zend_do_declare_property(znode *var_name, znode *value TSRMLS_DC)
|
|||
{
|
||||
zval *property;
|
||||
zend_property_info property_info;
|
||||
HashTable *target_symbol_table;
|
||||
|
||||
ALLOC_ZVAL(property);
|
||||
|
||||
|
@ -2224,19 +2225,18 @@ void zend_do_declare_property(znode *var_name, znode *value TSRMLS_DC)
|
|||
}
|
||||
|
||||
if (CG(access_type) & ZEND_ACC_STATIC) {
|
||||
/* FIXME: Currently, ignores access type for static variables */
|
||||
zend_hash_update(CG(active_class_entry)->static_members, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, &property, sizeof(zval *), NULL);
|
||||
FREE_PNODE(var_name);
|
||||
return;
|
||||
target_symbol_table = CG(active_class_entry)->static_members;
|
||||
} else {
|
||||
target_symbol_table = &CG(active_class_entry)->default_properties;
|
||||
}
|
||||
|
||||
switch (CG(access_type)) {
|
||||
switch (CG(access_type) & ZEND_ACC_PPP_MASK) {
|
||||
case ZEND_ACC_PRIVATE: {
|
||||
char *priv_name;
|
||||
int priv_name_length;
|
||||
|
||||
mangle_property_name(&priv_name, &priv_name_length, CG(active_class_entry)->name, CG(active_class_entry)->name_length, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len);
|
||||
zend_hash_update(&CG(active_class_entry)->default_properties, priv_name, priv_name_length+1, &property, sizeof(zval *), NULL);
|
||||
zend_hash_update(target_symbol_table, priv_name, priv_name_length+1, &property, sizeof(zval *), NULL);
|
||||
property_info.name = priv_name;
|
||||
property_info.name_length = priv_name_length;
|
||||
}
|
||||
|
@ -2246,13 +2246,13 @@ void zend_do_declare_property(znode *var_name, znode *value TSRMLS_DC)
|
|||
int prot_name_length;
|
||||
|
||||
mangle_property_name(&prot_name, &prot_name_length, "*", 1, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len);
|
||||
zend_hash_update(&CG(active_class_entry)->default_properties, prot_name, prot_name_length+1, &property, sizeof(zval *), NULL);
|
||||
zend_hash_update(target_symbol_table, prot_name, prot_name_length+1, &property, sizeof(zval *), NULL);
|
||||
property_info.name = prot_name;
|
||||
property_info.name_length = prot_name_length;
|
||||
}
|
||||
break;
|
||||
case ZEND_ACC_PUBLIC:
|
||||
zend_hash_update(&CG(active_class_entry)->default_properties, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, &property, sizeof(zval *), NULL);
|
||||
zend_hash_update(target_symbol_table, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, &property, sizeof(zval *), NULL);
|
||||
property_info.name = var_name->u.constant.value.str.val;
|
||||
property_info.name_length = var_name->u.constant.value.str.len;
|
||||
break;
|
||||
|
@ -2260,9 +2260,7 @@ void zend_do_declare_property(znode *var_name, znode *value TSRMLS_DC)
|
|||
property_info.flags = CG(access_type);
|
||||
property_info.h = zend_get_hash_value(property_info.name, property_info.name_length+1);
|
||||
|
||||
zend_hash_update(&CG(active_class_entry)->default_properties_info, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, &property_info, sizeof(zend_property_info), NULL);
|
||||
|
||||
/*FREE_PNODE(var_name);*/
|
||||
zend_hash_update(&CG(active_class_entry)->properties_info, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, &property_info, sizeof(zend_property_info), NULL);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -605,18 +605,6 @@ static void print_refcount(zval *p, char *str)
|
|||
print_refcount(NULL, NULL);
|
||||
}
|
||||
|
||||
static inline HashTable *zend_find_inherited_static(zend_class_entry *ce, zval *variable)
|
||||
{
|
||||
zend_class_entry *orig_ce = ce;
|
||||
|
||||
while (ce) {
|
||||
if (zend_hash_exists(ce->static_members, Z_STRVAL_P(variable), Z_STRLEN_P(variable)+1)) {
|
||||
return ce->static_members;
|
||||
}
|
||||
ce = ce->parent;
|
||||
}
|
||||
return orig_ce->static_members;
|
||||
}
|
||||
|
||||
static inline HashTable *zend_get_target_symbol_table(zend_op *opline, temp_variable *Ts, int type, zval *variable TSRMLS_DC)
|
||||
{
|
||||
|
@ -639,15 +627,6 @@ static inline HashTable *zend_get_target_symbol_table(zend_op *opline, temp_vari
|
|||
}
|
||||
return EG(active_op_array)->static_variables;
|
||||
break;
|
||||
case ZEND_FETCH_STATIC_MEMBER:
|
||||
if (T(opline->op2.u.var).EA.class_entry->parent) {
|
||||
/* if inherited, try to look up */
|
||||
return zend_find_inherited_static(T(opline->op2.u.var).EA.class_entry, variable);
|
||||
} else {
|
||||
/* if class is not inherited, no point in checking */
|
||||
return T(opline->op2.u.var).EA.class_entry->static_members;
|
||||
}
|
||||
break;
|
||||
EMPTY_SWITCH_DEFAULT_CASE()
|
||||
}
|
||||
return NULL;
|
||||
|
@ -669,37 +648,45 @@ static void zend_fetch_var_address(zend_op *opline, temp_variable *Ts, int type
|
|||
varname = &tmp_varname;
|
||||
}
|
||||
|
||||
target_symbol_table = zend_get_target_symbol_table(opline, Ts, type, varname TSRMLS_CC);
|
||||
if (!target_symbol_table) {
|
||||
return;
|
||||
}
|
||||
if (opline->op2.u.EA.type == ZEND_FETCH_STATIC_MEMBER) {
|
||||
target_symbol_table = NULL;
|
||||
retval = zend_get_static_property(T(opline->op2.u.var).EA.class_entry, Z_STRVAL_P(varname), Z_STRLEN_P(varname), type TSRMLS_CC);
|
||||
} else {
|
||||
target_symbol_table = zend_get_target_symbol_table(opline, Ts, type, varname TSRMLS_CC);
|
||||
if (!target_symbol_table) {
|
||||
return;
|
||||
}
|
||||
if (zend_hash_find(target_symbol_table, varname->value.str.val, varname->value.str.len+1, (void **) &retval) == FAILURE) {
|
||||
switch (type) {
|
||||
case BP_VAR_R:
|
||||
zend_error(E_NOTICE,"Undefined variable: %s", varname->value.str.val);
|
||||
/* break missing intentionally */
|
||||
case BP_VAR_IS:
|
||||
retval = &EG(uninitialized_zval_ptr);
|
||||
break;
|
||||
case BP_VAR_RW:
|
||||
zend_error(E_NOTICE,"Undefined variable: %s", varname->value.str.val);
|
||||
/* break missing intentionally */
|
||||
case BP_VAR_W: {
|
||||
zval *new_zval = &EG(uninitialized_zval);
|
||||
|
||||
if (zend_hash_find(target_symbol_table, varname->value.str.val, varname->value.str.len+1, (void **) &retval) == FAILURE) {
|
||||
switch (type) {
|
||||
case BP_VAR_R:
|
||||
zend_error(E_NOTICE,"Undefined variable: %s", varname->value.str.val);
|
||||
/* break missing intentionally */
|
||||
case BP_VAR_IS:
|
||||
retval = &EG(uninitialized_zval_ptr);
|
||||
new_zval->refcount++;
|
||||
zend_hash_update(target_symbol_table, varname->value.str.val, varname->value.str.len+1, &new_zval, sizeof(zval *), (void **) &retval);
|
||||
}
|
||||
break;
|
||||
EMPTY_SWITCH_DEFAULT_CASE()
|
||||
}
|
||||
}
|
||||
switch (opline->op2.u.EA.type) {
|
||||
case ZEND_FETCH_LOCAL:
|
||||
FREE_OP(Ts, &opline->op1, free_op1);
|
||||
break;
|
||||
case BP_VAR_RW:
|
||||
zend_error(E_NOTICE,"Undefined variable: %s", varname->value.str.val);
|
||||
/* break missing intentionally */
|
||||
case BP_VAR_W: {
|
||||
zval *new_zval = &EG(uninitialized_zval);
|
||||
|
||||
new_zval->refcount++;
|
||||
zend_hash_update(target_symbol_table, varname->value.str.val, varname->value.str.len+1, &new_zval, sizeof(zval *), (void **) &retval);
|
||||
}
|
||||
case ZEND_FETCH_STATIC:
|
||||
zval_update_constant(retval, (void *) 1 TSRMLS_CC);
|
||||
break;
|
||||
EMPTY_SWITCH_DEFAULT_CASE()
|
||||
}
|
||||
}
|
||||
if (opline->op2.u.EA.type == ZEND_FETCH_LOCAL) {
|
||||
FREE_OP(Ts, &opline->op1, free_op1);
|
||||
} else if (opline->op2.u.EA.type == ZEND_FETCH_STATIC || opline->op2.u.EA.type == ZEND_FETCH_STATIC_MEMBER) {
|
||||
zval_update_constant(retval, (void *) 1 TSRMLS_CC);
|
||||
}
|
||||
|
||||
|
||||
if (varname == &tmp_varname) {
|
||||
zval_dtor(varname);
|
||||
|
|
|
@ -153,30 +153,26 @@ static int zend_std_call_setter(zval *object, zval *member, zval *value TSRMLS_D
|
|||
}
|
||||
|
||||
|
||||
inline int zend_verify_property_access(zend_property_info *property_info, zend_object *zobj TSRMLS_DC)
|
||||
inline int zend_verify_property_access(zend_property_info *property_info, zend_class_entry *ce TSRMLS_DC)
|
||||
{
|
||||
switch (property_info->flags & ZEND_ACC_PPP_MASK) {
|
||||
case ZEND_ACC_PUBLIC:
|
||||
return 1;
|
||||
case ZEND_ACC_PRIVATE:
|
||||
if (zobj->ce == EG(scope)) {
|
||||
if (ce == EG(scope)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case ZEND_ACC_PROTECTED: {
|
||||
zend_class_entry *ce = zobj->ce;
|
||||
|
||||
while (ce) {
|
||||
if (ce==EG(scope)) {
|
||||
return 1;
|
||||
}
|
||||
ce = ce->parent;
|
||||
case ZEND_ACC_PROTECTED:
|
||||
while (ce) {
|
||||
if (ce==EG(scope)) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
ce = ce->parent;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -204,7 +200,7 @@ zval *zend_std_read_property(zval *object, zval *member, int type TSRMLS_DC)
|
|||
fprintf(stderr, "Read object #%d property: %s\n", Z_OBJ_HANDLE_P(object), Z_STRVAL_P(member));
|
||||
#endif
|
||||
|
||||
if (zend_hash_find(&zobj->ce->default_properties_info, Z_STRVAL_P(member), Z_STRLEN_P(member)+1, (void **) &property_info)==FAILURE) {
|
||||
if (zend_hash_find(&zobj->ce->properties_info, Z_STRVAL_P(member), Z_STRLEN_P(member)+1, (void **) &property_info)==FAILURE) {
|
||||
std_property_info.flags = ZEND_ACC_PUBLIC;
|
||||
std_property_info.name = Z_STRVAL_P(member);
|
||||
std_property_info.name_length = Z_STRLEN_P(member);
|
||||
|
@ -215,7 +211,7 @@ zval *zend_std_read_property(zval *object, zval *member, int type TSRMLS_DC)
|
|||
#if DEBUG_OBJECT_HANDLERS
|
||||
zend_printf("Access type for %s::%s is %s\n", zobj->ce->name, Z_STRVAL_P(member), zend_visibility_string(property_info->flags));
|
||||
#endif
|
||||
if (!zend_verify_property_access(property_info, zobj TSRMLS_CC)) {
|
||||
if (!zend_verify_property_access(property_info, zobj->ce TSRMLS_CC)) {
|
||||
zend_error(E_ERROR, "Cannot access %s property %s::$%s", zend_visibility_string(property_info->flags), zobj->ce->name, Z_STRVAL_P(member));
|
||||
}
|
||||
|
||||
|
@ -279,7 +275,7 @@ static void zend_std_write_property(zval *object, zval *member, zval *value TSRM
|
|||
member = &tmp_member;
|
||||
}
|
||||
|
||||
if (zend_hash_find(&zobj->ce->default_properties_info, Z_STRVAL_P(member), Z_STRLEN_P(member)+1, (void **) &property_info)==FAILURE) {
|
||||
if (zend_hash_find(&zobj->ce->properties_info, Z_STRVAL_P(member), Z_STRLEN_P(member)+1, (void **) &property_info)==FAILURE) {
|
||||
std_property_info.flags = ZEND_ACC_PUBLIC;
|
||||
std_property_info.name = Z_STRVAL_P(member);
|
||||
std_property_info.name_length = Z_STRLEN_P(member);
|
||||
|
@ -291,7 +287,7 @@ static void zend_std_write_property(zval *object, zval *member, zval *value TSRM
|
|||
zend_printf("Access type for %s::%s is %s\n", zobj->ce->name, Z_STRVAL_P(member), zend_visibility_string(property_info->flags));
|
||||
#endif
|
||||
|
||||
if (!zend_verify_property_access(property_info, zobj TSRMLS_CC)) {
|
||||
if (!zend_verify_property_access(property_info, zobj->ce TSRMLS_CC)) {
|
||||
zend_error(E_ERROR, "Cannot access %s property %s::$%s", zend_visibility_string(property_info->flags), zobj->ce->name, Z_STRVAL_P(member));
|
||||
}
|
||||
|
||||
|
@ -354,7 +350,7 @@ static zval **zend_std_get_property_ptr(zval *object, zval *member TSRMLS_DC)
|
|||
member = &tmp_member;
|
||||
}
|
||||
|
||||
if (zend_hash_find(&zobj->ce->default_properties_info, Z_STRVAL_P(member), Z_STRLEN_P(member)+1, (void **) &property_info)==FAILURE) {
|
||||
if (zend_hash_find(&zobj->ce->properties_info, Z_STRVAL_P(member), Z_STRLEN_P(member)+1, (void **) &property_info)==FAILURE) {
|
||||
std_property_info.flags = ZEND_ACC_PUBLIC;
|
||||
std_property_info.name = Z_STRVAL_P(member);
|
||||
std_property_info.name_length = Z_STRLEN_P(member);
|
||||
|
@ -366,7 +362,7 @@ static zval **zend_std_get_property_ptr(zval *object, zval *member TSRMLS_DC)
|
|||
fprintf(stderr, "Ptr object #%d property: %s\n", Z_OBJ_HANDLE_P(object), Z_STRVAL_P(member));
|
||||
#endif
|
||||
|
||||
if (!zend_verify_property_access(property_info, zobj TSRMLS_CC)) {
|
||||
if (!zend_verify_property_access(property_info, zobj->ce TSRMLS_CC)) {
|
||||
zend_error(E_ERROR, "Cannot access %s property %s::$%s", zend_visibility_string(property_info->flags), zobj->ce->name, Z_STRVAL_P(member));
|
||||
}
|
||||
|
||||
|
@ -649,6 +645,64 @@ zend_function *zend_get_static_method(zend_class_entry *ce, char *function_name_
|
|||
}
|
||||
|
||||
|
||||
zval **zend_get_static_property(zend_class_entry *ce, char *property_name, int property_name_len, int type TSRMLS_DC)
|
||||
{
|
||||
HashTable *statics_table;
|
||||
zval **retval = NULL;
|
||||
zend_class_entry *tmp_ce = ce;
|
||||
zend_property_info *property_info;
|
||||
zend_property_info std_property_info;
|
||||
|
||||
if (zend_hash_find(&ce->properties_info, property_name, property_name_len+1, (void **) &property_info)==FAILURE) {
|
||||
std_property_info.flags = ZEND_ACC_PUBLIC;
|
||||
std_property_info.name = property_name;
|
||||
std_property_info.name_length = property_name_len;
|
||||
std_property_info.h = zend_get_hash_value(std_property_info.name, std_property_info.name_length+1);
|
||||
property_info = &std_property_info;
|
||||
}
|
||||
|
||||
#if 1&&DEBUG_OBJECT_HANDLERS
|
||||
zend_printf("Access type for %s::%s is %s\n", ce->name, property_name, zend_visibility_string(property_info->flags));
|
||||
#endif
|
||||
|
||||
if (!zend_verify_property_access(property_info, ce TSRMLS_CC)) {
|
||||
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) {
|
||||
statics_table = tmp_ce->static_members;
|
||||
break;
|
||||
}
|
||||
tmp_ce = tmp_ce->parent;
|
||||
}
|
||||
|
||||
if (!retval) {
|
||||
switch (type) {
|
||||
case BP_VAR_R:
|
||||
zend_error(E_NOTICE,"Undefined variable: %s::$%s", ce->name, property_name);
|
||||
/* break missing intentionally */
|
||||
case BP_VAR_IS:
|
||||
retval = &EG(uninitialized_zval_ptr);
|
||||
break;
|
||||
case BP_VAR_RW:
|
||||
zend_error(E_NOTICE,"Undefined variable: %s::$%s", ce->name, property_name);
|
||||
/* break missing intentionally */
|
||||
case BP_VAR_W: {
|
||||
zval *new_zval = &EG(uninitialized_zval);
|
||||
|
||||
new_zval->refcount++;
|
||||
zend_hash_quick_update(ce->static_members, property_info->name, property_info->name_length+1, property_info->h, &new_zval, sizeof(zval *), (void **) &retval);
|
||||
}
|
||||
break;
|
||||
EMPTY_SWITCH_DEFAULT_CASE()
|
||||
}
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
static union _zend_function *zend_std_get_constructor(zval *object TSRMLS_DC)
|
||||
{
|
||||
zend_object *zobj = Z_OBJ_P(object);
|
||||
|
|
|
@ -94,6 +94,7 @@ typedef struct _zend_object_handlers {
|
|||
|
||||
extern zend_object_handlers std_object_handlers;
|
||||
union _zend_function *zend_get_static_method(zend_class_entry *ce, char *function_name_strval, int function_name_strlen TSRMLS_DC);
|
||||
zval **zend_get_static_property(zend_class_entry *ce, char *property_name, int property_name_len, int type TSRMLS_DC);
|
||||
|
||||
|
||||
#define IS_ZEND_STD_OBJECT(z) ((z).type == IS_OBJECT && (Z_OBJ_HT((z))->get_class_entry != NULL))
|
||||
|
|
|
@ -146,7 +146,7 @@ ZEND_API void destroy_zend_class(zend_class_entry **pce)
|
|||
switch (ce->type) {
|
||||
case ZEND_USER_CLASS:
|
||||
zend_hash_destroy(&ce->default_properties);
|
||||
zend_hash_destroy(&ce->default_properties_info);
|
||||
zend_hash_destroy(&ce->properties_info);
|
||||
zend_hash_destroy(ce->static_members);
|
||||
efree(ce->name);
|
||||
zend_hash_destroy(&ce->function_table);
|
||||
|
@ -157,7 +157,7 @@ ZEND_API void destroy_zend_class(zend_class_entry **pce)
|
|||
break;
|
||||
case ZEND_INTERNAL_CLASS:
|
||||
zend_hash_destroy(&ce->default_properties);
|
||||
zend_hash_destroy(&ce->default_properties_info);
|
||||
zend_hash_destroy(&ce->properties_info);
|
||||
zend_hash_destroy(ce->static_members);
|
||||
free(ce->name);
|
||||
zend_hash_destroy(&ce->function_table);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue