--- /dev/null
+--TEST--
+Bug #64070 (Inheritance with Traits failed with error)
+--FILE--
+<?php
+trait first_trait
+{
+ function first_function()
+ {
+ echo "From First Trait\n";
+ }
+}
+
+trait second_trait
+{
+ use first_trait {
+ first_trait::first_function as second_function;
+ }
+
+ function first_function()
+ {
+ echo "From Second Trait\n";
+ }
+}
+
+class first_class
+{
+ use second_trait;
+}
+
+$obj = new first_class();
+$obj->first_function();
+$obj->second_function();
+?>
+--EXPECT--
+From Second Trait
+From First Trait
overriden = va_arg(args, HashTable**);
exclude_table = va_arg(args, HashTable*);
- fnname_len = strlen(fn->common.function_name);
+ fnname_len = hash_key->nKeyLength - 1;
/* apply aliases which are qualified with a class name, there should not be any ambiguity */
if (ce->trait_aliases) {
if (alias->alias != NULL
&& (!alias->trait_method->ce || fn->common.scope == alias->trait_method->ce)
&& alias->trait_method->mname_len == fnname_len
- && (zend_binary_strcasecmp(alias->trait_method->method_name, alias->trait_method->mname_len, fn->common.function_name, fnname_len) == 0)) {
+ && (zend_binary_strcasecmp(alias->trait_method->method_name, alias->trait_method->mname_len, hash_key->arKey, fnname_len) == 0)) {
fn_copy = *fn;
/* if it is 0, no modifieres has been changed */
}
}
- lcname = zend_str_tolower_dup(fn->common.function_name, fnname_len);
+ lcname = hash_key->arKey;
if (exclude_table == NULL || zend_hash_find(exclude_table, lcname, fnname_len, &dummy) == FAILURE) {
/* is not in hashtable, thus, function is not to be excluded */
if (alias->alias == NULL && alias->modifiers != 0
&& (!alias->trait_method->ce || fn->common.scope == alias->trait_method->ce)
&& (alias->trait_method->mname_len == fnname_len)
- && (zend_binary_strcasecmp(alias->trait_method->method_name, alias->trait_method->mname_len, fn->common.function_name, fnname_len) == 0)) {
+ && (zend_binary_strcasecmp(alias->trait_method->method_name, alias->trait_method->mname_len, lcname, fnname_len) == 0)) {
fn_copy.common.fn_flags = alias->modifiers | (fn->common.fn_flags ^ (fn->common.fn_flags & ZEND_ACC_PPP_MASK));
zend_add_trait_method(ce, fn->common.function_name, lcname, fnname_len+1, &fn_copy, overriden TSRMLS_CC);
}
- efree(lcname);
-
return ZEND_HASH_APPLY_KEEP;
}
/* }}} */