Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions Zend/tests/bug64070.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
--TEST--
Bug #64070 (Inheritance with traits and aliased methods)
--FILE--
<?php

trait Foo {
public function bar() {
echo "foo\n";
}
}

trait Bar {
use Foo {
Foo::bar as foo;
}

public function bar() {
echo "bar\n";
}
}

class Boo {
use Bar;
}

$n = new Boo;
$n->bar();
$n->foo();

?>
--EXPECT--
bar
foo
3 changes: 3 additions & 0 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down