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:
Dmitry Stogov 2016-06-22 17:28:59 +03:00
commit f8faffe37e
2 changed files with 15 additions and 5 deletions

View file

@ -2477,8 +2477,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 = "->";
@ -2538,6 +2540,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) {
@ -2702,9 +2709,10 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int
if (object) {
if (func->common.scope) {
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);
} 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);
if ((options & DEBUG_BACKTRACE_PROVIDE_OBJECT) != 0) {

View file

@ -527,13 +527,15 @@ 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;
}
}
}
/* }}} */
static void _build_trace_string(smart_str *str, HashTable *ht, uint32_t num) /* {{{ */