mirror of
https://github.com/php/php-src.git
synced 2024-11-28 12:26:37 +08:00
Fixed debug_zval_dump() to support private and protected members
This commit is contained in:
parent
6dff869c51
commit
97f463c156
1
NEWS
1
NEWS
@ -1,6 +1,7 @@
|
||||
PHP NEWS
|
||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
?? Mar 2006, PHP 5.1.3RC2
|
||||
- Fixed debug_zval_dump() to support private and protected members. (Dmitry)
|
||||
|
||||
09 Mar 2006, PHP 5.1.3RC1
|
||||
- Updated PCRE to version 6.6. (Andrei)
|
||||
|
@ -221,12 +221,44 @@ static int zval_array_element_dump(zval **zv, int num_args, va_list args, zend_h
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int zval_object_property_dump(zval **zv, int num_args, va_list args, zend_hash_key *hash_key)
|
||||
{
|
||||
int level;
|
||||
char *prop_name, *class_name;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
level = va_arg(args, int);
|
||||
|
||||
if (hash_key->nKeyLength ==0 ) { /* numeric key */
|
||||
php_printf("%*c[%ld]=>\n", level + 1, ' ', hash_key->h);
|
||||
} else { /* string key */
|
||||
zend_unmangle_property_name_ex(hash_key->arKey, hash_key->nKeyLength, &class_name, &prop_name);
|
||||
if (class_name) {
|
||||
php_printf("%*c[\"%s", level + 1, ' ', prop_name);
|
||||
if (class_name[0]=='*') {
|
||||
ZEND_PUTS(":protected");
|
||||
} else {
|
||||
ZEND_PUTS(":private");
|
||||
}
|
||||
} else {
|
||||
php_printf("%*c[\"%s", level + 1, ' ', hash_key->arKey);
|
||||
#ifdef ANDREY_0
|
||||
ZEND_PUTS(":public");
|
||||
#endif
|
||||
}
|
||||
ZEND_PUTS("\"]=>\n");
|
||||
}
|
||||
php_debug_zval_dump(zv, level + 2 TSRMLS_CC);
|
||||
return 0;
|
||||
}
|
||||
|
||||
PHPAPI void php_debug_zval_dump(zval **struc, int level TSRMLS_DC)
|
||||
{
|
||||
HashTable *myht = NULL;
|
||||
char *class_name;
|
||||
zend_uint class_name_len;
|
||||
zend_class_entry *ce;
|
||||
int (*zval_element_dump_func)(zval**, int, va_list, zend_hash_key*);
|
||||
|
||||
if (level > 1) {
|
||||
php_printf("%*c", level - 1, ' ');
|
||||
@ -257,6 +289,7 @@ PHPAPI void php_debug_zval_dump(zval **struc, int level TSRMLS_DC)
|
||||
return;
|
||||
}
|
||||
php_printf("%sarray(%d) refcount(%u){\n", COMMON, zend_hash_num_elements(myht), Z_REFCOUNT_PP(struc));
|
||||
zval_element_dump_func = zval_array_element_dump;
|
||||
goto head_done;
|
||||
case IS_OBJECT:
|
||||
myht = Z_OBJPROP_PP(struc);
|
||||
@ -268,9 +301,10 @@ PHPAPI void php_debug_zval_dump(zval **struc, int level TSRMLS_DC)
|
||||
Z_OBJ_HANDLER(**struc, get_class_name)(*struc, &class_name, &class_name_len, 0 TSRMLS_CC);
|
||||
php_printf("%sobject(%s)#%d (%d) refcount(%u){\n", COMMON, class_name, Z_OBJ_HANDLE_PP(struc), myht ? zend_hash_num_elements(myht) : 0, Z_REFCOUNT_PP(struc));
|
||||
efree(class_name);
|
||||
zval_element_dump_func = zval_object_property_dump;
|
||||
head_done:
|
||||
if (myht) {
|
||||
zend_hash_apply_with_arguments(myht, (apply_func_args_t) zval_array_element_dump, 1, level, (Z_TYPE_PP(struc) == IS_ARRAY ? 0 : 1));
|
||||
zend_hash_apply_with_arguments(myht, (apply_func_args_t) zval_element_dump_func, 1, level, (Z_TYPE_PP(struc) == IS_ARRAY ? 0 : 1));
|
||||
}
|
||||
if (level > 1) {
|
||||
php_printf("%*c", level-1, ' ');
|
||||
|
Loading…
Reference in New Issue
Block a user