diff options
author | Xinchen Hui <laruence@php.net> | 2013-03-21 21:10:32 +0800 |
---|---|---|
committer | Xinchen Hui <laruence@php.net> | 2013-03-21 21:10:32 +0800 |
commit | 79925094c40a46a270fc079ddd6c2c92ff62c10f (patch) | |
tree | 06c69df2c9ef320294ae384500bf4159f2d518f9 /Zend/zend_API.c | |
parent | f2383dead69d59143fee1d54de98f154d6833714 (diff) | |
parent | 7dce0194c815cdc75a780b6471660042aed7bd7a (diff) | |
download | php-git-79925094c40a46a270fc079ddd6c2c92ff62c10f.tar.gz |
Merge branch 'PHP-5.4' into PHP-5.5
Diffstat (limited to 'Zend/zend_API.c')
-rw-r--r-- | Zend/zend_API.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 1f400dea13..e867ca5dac 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -3976,6 +3976,62 @@ ZEND_API void zend_restore_error_handling(zend_error_handling *saved TSRMLS_DC) } /* }}} */ +ZEND_API const char* zend_find_alias_name(zend_class_entry *ce, const char *name, zend_uint len) /* {{{ */ +{ + zend_trait_alias *alias, **alias_ptr; + + alias_ptr = ce->trait_aliases; + alias = *alias_ptr; + while (alias) { + if (alias->alias_len == len && + !strncasecmp(name, alias->alias, alias->alias_len)) { + return alias->alias; + } + alias_ptr++; + alias = *alias_ptr; + } + + return name; +} +/* }}} */ + +ZEND_API const char* zend_resolve_method_name(zend_class_entry *ce, zend_function *f) /* {{{ */ +{ + zend_function *func; + HashPosition iterator; + HashTable *function_table; + + if (f->common.type != ZEND_USER_FUNCTION || + *(f->op_array.refcount) < 2 || + !f->common.scope || + !f->common.scope->trait_aliases) { + 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 == f) { + 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) && + !strncasecmp(name, f->common.function_name, len)) { + return f->common.function_name; + } + return zend_find_alias_name(f->common.scope, name, len); + } + zend_hash_move_forward_ex(function_table, &iterator); + } + return f->common.function_name; +} +/* }}} */ + /* * Local variables: * tab-width: 4 |