diff --git a/Zend/tests/bug64070.phpt b/Zend/tests/bug64070.phpt new file mode 100644 index 0000000000000..e887a828c4886 --- /dev/null +++ b/Zend/tests/bug64070.phpt @@ -0,0 +1,33 @@ +--TEST-- +Bug #64070 (Inheritance with traits and aliased methods) +--FILE-- +bar(); +$n->foo(); + +?> +--EXPECT-- +bar +foo diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 1a8d10890060b..6adceb4f72be0 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -3988,6 +3988,9 @@ static int zend_traits_copy_functions(zend_function *fn TSRMLS_DC, int num_args, && 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)) { fn_copy = *fn; + + /* Switch the name of the aliased function to the alias so that derived classes will get alias and not original name */ + fn_copy.common.function_name = estrndup(alias->alias, alias->alias_len); /* if it is 0, no modifieres has been changed */ if (alias->modifiers) {