--- embedaddon/php/Zend/zend_builtin_functions.c 2012/05/29 12:34:35 1.1.1.2 +++ embedaddon/php/Zend/zend_builtin_functions.c 2013/07/22 01:32:15 1.1.1.3 @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | Zend Engine | +----------------------------------------------------------------------+ - | Copyright (c) 1998-2012 Zend Technologies Ltd. (http://www.zend.com) | + | Copyright (c) 1998-2013 Zend Technologies Ltd. (http://www.zend.com) | +----------------------------------------------------------------------+ | This source file is subject to version 2.00 of the Zend license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_builtin_functions.c,v 1.1.1.2 2012/05/29 12:34:35 misho Exp $ */ +/* $Id: zend_builtin_functions.c,v 1.1.1.3 2013/07/22 01:32:15 misho Exp $ */ #include "zend.h" #include "zend_API.h" @@ -1025,6 +1025,13 @@ ZEND_FUNCTION(get_object_vars) } /* }}} */ +static int same_name(const char *key, const char *name, zend_uint name_len) +{ + char *lcname = zend_str_tolower_dup(name, name_len); + int ret = memcmp(lcname, key, name_len) == 0; + efree(lcname); + return ret; +} /* {{{ proto array get_class_methods(mixed class) Returns an array of method names for class or class instance. */ @@ -1072,14 +1079,26 @@ ZEND_FUNCTION(get_class_methods) uint len = strlen(mptr->common.function_name); /* Do not display old-style inherited constructors */ - if ((mptr->common.fn_flags & ZEND_ACC_CTOR) == 0 || - mptr->common.scope == ce || - zend_hash_get_current_key_ex(&ce->function_table, &key, &key_len, &num_index, 0, &pos) != HASH_KEY_IS_STRING || - zend_binary_strcasecmp(key, key_len-1, mptr->common.function_name, len) == 0) { - + if (zend_hash_get_current_key_ex(&ce->function_table, &key, &key_len, &num_index, 0, &pos) != HASH_KEY_IS_STRING) { MAKE_STD_ZVAL(method_name); ZVAL_STRINGL(method_name, mptr->common.function_name, len, 1); zend_hash_next_index_insert(return_value->value.ht, &method_name, sizeof(zval *), NULL); + } else if ((mptr->common.fn_flags & ZEND_ACC_CTOR) == 0 || + mptr->common.scope == ce || + zend_binary_strcasecmp(key, key_len-1, mptr->common.function_name, len) == 0) { + + if (mptr->type == ZEND_USER_FUNCTION && + *mptr->op_array.refcount > 1 && + (len != key_len - 1 || + !same_name(key, mptr->common.function_name, len))) { + MAKE_STD_ZVAL(method_name); + 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); + ZVAL_STRINGL(method_name, mptr->common.function_name, len, 1); + zend_hash_next_index_insert(return_value->value.ht, &method_name, sizeof(zval *), NULL); + } } } zend_hash_move_forward_ex(&ce->function_table, &pos); @@ -1640,7 +1659,6 @@ ZEND_FUNCTION(restore_exception_handler) } /* }}} */ - static int copy_class_or_interface_name(zend_class_entry **pce TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) { zval *array = va_arg(args, zval *); @@ -1651,7 +1669,13 @@ static int copy_class_or_interface_name(zend_class_ent if ((hash_key->nKeyLength==0 || hash_key->arKey[0]!=0) && (comply_mask == (ce->ce_flags & mask))) { - add_next_index_stringl(array, ce->name, ce->name_length, 1); + if (ce->refcount > 1 && + (ce->name_length != hash_key->nKeyLength - 1 || + !same_name(hash_key->arKey, ce->name, ce->name_length))) { + add_next_index_stringl(array, hash_key->arKey, hash_key->nKeyLength - 1, 1); + } else { + add_next_index_stringl(array, ce->name, ce->name_length, 1); + } } return ZEND_HASH_APPLY_KEEP; } @@ -2094,7 +2118,14 @@ ZEND_FUNCTION(debug_print_backtrace) lineno = 0; } - function_name = ptr->function_state.function->common.function_name; + function_name = (ptr->function_state.function->common.scope && + ptr->function_state.function->common.scope->trait_aliases) ? + zend_resolve_method_name( + ptr->object ? + Z_OBJCE_P(ptr->object) : + ptr->function_state.function->common.scope, + ptr->function_state.function) : + ptr->function_state.function->common.function_name; if (function_name) { if (ptr->object) { @@ -2275,7 +2306,14 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_ filename = NULL; } - function_name = ptr->function_state.function->common.function_name; + function_name = (ptr->function_state.function->common.scope && + ptr->function_state.function->common.scope->trait_aliases) ? + zend_resolve_method_name( + ptr->object ? + Z_OBJCE_P(ptr->object) : + ptr->function_state.function->common.scope, + 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);