diff options
| author | Zeev Suraski <zeev@php.net> | 2003-06-08 18:53:58 +0000 |
|---|---|---|
| committer | Zeev Suraski <zeev@php.net> | 2003-06-08 18:53:58 +0000 |
| commit | d329ce93f2bbda9cb72497b0e95ebc608161c9ce (patch) | |
| tree | a53cb22d4d038a9e727991e2c793c38ac242766f | |
| parent | faefdb7bddccf8cacb42ebda79e2709b661d1594 (diff) | |
| download | php-git-d329ce93f2bbda9cb72497b0e95ebc608161c9ce.tar.gz | |
Nicer handling of protected/private members in print_r()
| -rw-r--r-- | Zend/zend.c | 22 | ||||
| -rw-r--r-- | Zend/zend_compile.c | 13 | ||||
| -rw-r--r-- | Zend/zend_compile.h | 1 |
3 files changed, 32 insertions, 4 deletions
diff --git a/Zend/zend.c b/Zend/zend.c index 8c57996742..b3f415bd26 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -112,7 +112,7 @@ static uint zend_version_info_length; #define PRINT_ZVAL_INDENT 4 -static void print_hash(HashTable *ht, int indent TSRMLS_DC) +static void print_hash(HashTable *ht, int indent, zend_bool is_object TSRMLS_DC) { zval **tmp; char *string_key; @@ -134,7 +134,21 @@ static void print_hash(HashTable *ht, int indent TSRMLS_DC) ZEND_PUTS("["); switch (zend_hash_get_current_key_ex(ht, &string_key, &str_len, &num_key, 0, &iterator)) { case HASH_KEY_IS_STRING: - ZEND_PUTS(string_key); + if (is_object) { + char *prop_name, *class_name; + + unmangle_property_name(string_key, &class_name, &prop_name); + ZEND_PUTS(prop_name); + if (class_name) { + if (class_name[0]=='*') { + ZEND_PUTS(":protected"); + } else { + ZEND_PUTS(":private"); + } + } + } else { + ZEND_PUTS(string_key); + } break; case HASH_KEY_IS_LONG: zend_printf("%ld", num_key); @@ -331,7 +345,7 @@ ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int expr->value.ht->nApplyCount--; return; } - print_hash(expr->value.ht, indent TSRMLS_CC); + print_hash(expr->value.ht, indent, 0 TSRMLS_CC); expr->value.ht->nApplyCount--; break; case IS_OBJECT: @@ -356,7 +370,7 @@ ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int properties->nApplyCount--; return; } - print_hash(properties, indent TSRMLS_CC); + print_hash(properties, indent, 1 TSRMLS_CC); properties->nApplyCount--; } break; diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 28e9218be2..31e433c835 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -2357,6 +2357,19 @@ void mangle_property_name(char **dest, int *dest_length, char *src1, int src1_le } +void unmangle_property_name(char *mangled_property, char **class_name, char **prop_name) +{ + *prop_name = *class_name = NULL; + + if (mangled_property[0]!=0) { + *prop_name = mangled_property; + return; + } + + *class_name = mangled_property+1; + *prop_name = (*class_name)+strlen(*class_name)+1; +} + void zend_do_declare_property(znode *var_name, znode *value, zend_uint access_type TSRMLS_DC) { zval *property; diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 9db2224b97..dbc71e9b77 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -455,6 +455,7 @@ ZEND_API void destroy_zend_function(zend_function *function TSRMLS_DC); ZEND_API void destroy_zend_class(zend_class_entry **pce); void zend_class_add_ref(zend_class_entry **ce); +void unmangle_property_name(char *mangled_property, char **prop_name, char **class_name); void zend_duplicate_property_info(zend_property_info *property_info); void zend_destroy_property_info(zend_property_info *property_info); |
