php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | |
Patch bug64239-2.patch for *General Issues Bug #64239Patch version 2013-03-21 07:55 UTC Return to Bug #64239 | Download this patchThis patch is obsolete Obsoleted by patches: Patch Revisions:Developer: dmitry@zend.comdiff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index dcb1818..0141056 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -1033,6 +1033,80 @@ static int same_name(const char *key, const char *name, zend_uint name_len) return ret; } +static int zend_class_has_aliases(zend_class_entry *ce) +{ + while (1) { + if (ce) { + if (ce->trait_aliases) { + return 1; + } else { + ce = ce->parent; + } + } else { + return 0; + } + } +} + +static const char* zend_find_alias_name(zend_class_entry *ce, const char *name, zend_uint len) +{ + zend_trait_alias *alias, **alias_ptr; + + do { + alias_ptr = ce->trait_aliases; + alias = *alias_ptr; + while (alias) { + if (alias->alias_len == len && + same_name(name, alias->alias, alias->alias_len)) { + return alias->alias; + } + alias_ptr++; + alias = *alias_ptr; + } + } while ((ce = ce->parent)); + + return name; +} + +ZEND_API const char* zend_resolve_method_name(zend_function *f) +{ + zend_function *func; + HashPosition iterator; + zend_class_entry *ce; + HashTable *function_table; + + if (f->common.type != ZEND_USER_FUNCTION || *(f->op_array.refcount) < 2) { + return f->common.function_name; + } + + ce = f->common.scope; + if (!zend_class_has_aliases(ce)) { + return f->common.function_name; + } + + function_table = &ce->function_table; + zend_hash_internal_pointer_reset_ex(function_table, &iterator); + while (zend_hash_get_current_data_ex(function_table, (void **)&func, &iterator) == SUCCESS) { + if (func->op_array.opcodes == f->op_array.opcodes) { + char *name; + uint len; + ulong idx; + + if (zend_hash_get_current_key_ex(function_table, &name, &len, &idx, 0, &iterator) != HASH_KEY_IS_STRING) { + return f->common.function_name; + } + --len; + if (len == strlen(f->common.function_name) && + same_name(name, f->common.function_name, len)) { + return f->common.function_name; + } + return zend_find_alias_name(ce, name, len); + } + zend_hash_move_forward_ex(function_table, &iterator); + } + return f->common.function_name; +} + /* {{{ proto array get_class_methods(mixed class) Returns an array of method names for class or class instance. */ ZEND_FUNCTION(get_class_methods) @@ -1092,7 +1166,7 @@ ZEND_FUNCTION(get_class_methods) (len != key_len - 1 || !same_name(key, mptr->common.function_name, len))) { MAKE_STD_ZVAL(method_name); - ZVAL_STRINGL(method_name, key, key_len - 1, 1); + ZVAL_STRINGL(method_name, zend_find_alias_name(mptr->common.scope, key, key_len - 1), key_len - 1, 1); zend_hash_next_index_insert(return_value->value.ht, &method_name, sizeof(zval *), NULL); } else { MAKE_STD_ZVAL(method_name); @@ -2118,7 +2192,9 @@ ZEND_FUNCTION(debug_print_backtrace) lineno = 0; } - function_name = ptr->function_state.function->common.function_name; + function_name = ptr->function_state.function->common.scope ? + zend_resolve_method_name(ptr->function_state.function) : + ptr->function_state.function->common.function_name; if (function_name) { if (ptr->object) { @@ -2299,7 +2375,9 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int filename = NULL; } - function_name = ptr->function_state.function->common.function_name; + function_name = ptr->function_state.function->common.scope ? + zend_resolve_method_name(ptr->function_state.function) : + ptr->function_state.function->common.function_name; if (function_name) { add_assoc_string_ex(stack_frame, "function", sizeof("function"), (char*)function_name, 1); |
Copyright © 2001-2024 The PHP Group All rights reserved. |
Last updated: Sun Nov 24 02:01:28 2024 UTC |