mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Allow "proxy" ovjects to substitute their class names through get_class_name() handler (similar to var_dump() and others).
This commit is contained in:
parent
c196f9cdf7
commit
3c84e5e1ce
2 changed files with 17 additions and 5 deletions
|
@ -2388,8 +2388,10 @@ ZEND_FUNCTION(debug_print_backtrace)
|
|||
if (object) {
|
||||
if (func->common.scope) {
|
||||
class_name = func->common.scope->name;
|
||||
} else {
|
||||
} else if (object->handlers->get_class_name == std_object_handlers.get_class_name) {
|
||||
class_name = object->ce->name;
|
||||
} else {
|
||||
class_name = object->handlers->get_class_name(object);
|
||||
}
|
||||
|
||||
call_type = "->";
|
||||
|
@ -2449,6 +2451,11 @@ ZEND_FUNCTION(debug_print_backtrace)
|
|||
if (class_name) {
|
||||
ZEND_PUTS(ZSTR_VAL(class_name));
|
||||
ZEND_PUTS(call_type);
|
||||
if (object
|
||||
&& !func->common.scope
|
||||
&& object->handlers->get_class_name != std_object_handlers.get_class_name) {
|
||||
zend_string_release(class_name);
|
||||
}
|
||||
}
|
||||
zend_printf("%s(", function_name);
|
||||
if (Z_TYPE(arg_array) != IS_UNDEF) {
|
||||
|
@ -2608,9 +2615,12 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int
|
|||
if (object) {
|
||||
if (func->common.scope) {
|
||||
add_assoc_str_ex(&stack_frame, "class", sizeof("class")-1, zend_string_copy(func->common.scope->name));
|
||||
} else {
|
||||
} else if (object->handlers->get_class_name == std_object_handlers.get_class_name) {
|
||||
add_assoc_str_ex(&stack_frame, "class", sizeof("class")-1, zend_string_copy(object->ce->name));
|
||||
|
||||
} else {
|
||||
zend_string *class_name = object->handlers->get_class_name(object);
|
||||
add_assoc_str_ex(&stack_frame, "class", sizeof("class")-1, class_name);
|
||||
zend_string_release(class_name);
|
||||
}
|
||||
if ((options & DEBUG_BACKTRACE_PROVIDE_OBJECT) != 0) {
|
||||
zval zv;
|
||||
|
|
|
@ -563,11 +563,13 @@ static void _build_trace_args(zval *arg, smart_str *str) /* {{{ */
|
|||
case IS_ARRAY:
|
||||
smart_str_appends(str, "Array, ");
|
||||
break;
|
||||
case IS_OBJECT:
|
||||
case IS_OBJECT: {
|
||||
zend_string *class_name = Z_OBJ_HANDLER_P(arg, get_class_name)(Z_OBJ_P(arg));
|
||||
smart_str_appends(str, "Object(");
|
||||
smart_str_appends(str, ZSTR_VAL(Z_OBJCE_P(arg)->name));
|
||||
smart_str_appends(str, ZSTR_VAL(class_name));
|
||||
smart_str_appends(str, "), ");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue