mirror of
https://github.com/php/php-src.git
synced 2025-08-16 14:08:47 +02:00
Merge branch 'PHP-7.0'
* PHP-7.0: Allow "proxy" ovjects to substitute their class names through get_class_name() handler (similar to var_dump() and others).
This commit is contained in:
commit
f8faffe37e
2 changed files with 15 additions and 5 deletions
|
@ -2477,8 +2477,10 @@ ZEND_FUNCTION(debug_print_backtrace)
|
||||||
if (object) {
|
if (object) {
|
||||||
if (func->common.scope) {
|
if (func->common.scope) {
|
||||||
class_name = func->common.scope->name;
|
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;
|
class_name = object->ce->name;
|
||||||
|
} else {
|
||||||
|
class_name = object->handlers->get_class_name(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
call_type = "->";
|
call_type = "->";
|
||||||
|
@ -2538,6 +2540,11 @@ ZEND_FUNCTION(debug_print_backtrace)
|
||||||
if (class_name) {
|
if (class_name) {
|
||||||
ZEND_PUTS(ZSTR_VAL(class_name));
|
ZEND_PUTS(ZSTR_VAL(class_name));
|
||||||
ZEND_PUTS(call_type);
|
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);
|
zend_printf("%s(", function_name);
|
||||||
if (Z_TYPE(arg_array) != IS_UNDEF) {
|
if (Z_TYPE(arg_array) != IS_UNDEF) {
|
||||||
|
@ -2702,9 +2709,10 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int
|
||||||
if (object) {
|
if (object) {
|
||||||
if (func->common.scope) {
|
if (func->common.scope) {
|
||||||
ZVAL_STR_COPY(&tmp, func->common.scope->name);
|
ZVAL_STR_COPY(&tmp, func->common.scope->name);
|
||||||
} else {
|
} else if (object->handlers->get_class_name == std_object_handlers.get_class_name) {
|
||||||
ZVAL_STR_COPY(&tmp, object->ce->name);
|
ZVAL_STR_COPY(&tmp, object->ce->name);
|
||||||
|
} else {
|
||||||
|
ZVAL_STR(&tmp, object->handlers->get_class_name(object));
|
||||||
}
|
}
|
||||||
zend_hash_add_new(Z_ARRVAL(stack_frame), CG(known_strings)[ZEND_STR_CLASS], &tmp);
|
zend_hash_add_new(Z_ARRVAL(stack_frame), CG(known_strings)[ZEND_STR_CLASS], &tmp);
|
||||||
if ((options & DEBUG_BACKTRACE_PROVIDE_OBJECT) != 0) {
|
if ((options & DEBUG_BACKTRACE_PROVIDE_OBJECT) != 0) {
|
||||||
|
|
|
@ -527,11 +527,13 @@ static void _build_trace_args(zval *arg, smart_str *str) /* {{{ */
|
||||||
case IS_ARRAY:
|
case IS_ARRAY:
|
||||||
smart_str_appends(str, "Array, ");
|
smart_str_appends(str, "Array, ");
|
||||||
break;
|
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, "Object(");
|
||||||
smart_str_appends(str, ZSTR_VAL(Z_OBJCE_P(arg)->name));
|
smart_str_appends(str, ZSTR_VAL(class_name));
|
||||||
smart_str_appends(str, "), ");
|
smart_str_appends(str, "), ");
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue