mirror of
https://github.com/php/php-src.git
synced 2026-03-24 08:12:21 +01:00
Currently, trait methods are aliased will continue to use the original function name. In a few places in the codebase, we will try to look up the actual method name instead. However, this does not work if an aliased method is used indirectly (https://bugs.php.net/bug.php?id=69180). I think it would be better to instead actually change the method name to the alias. This is in principle easy: We have to allow function_name to be changed even if op array is otherwise shared (similar to static_variables). This means we need to addref/release the function_name separately, but I don't think there is a performance concern here (especially as everything is usually interned). There is a bit of complication in opcache, where we need to make sure that the function name is released the correct number of times (interning may overwrite the name in the original op_array, but we need to release it as many times as the op_array is shared). Fixes bug #69180. Fixes bug #74939. Closes GH-5226.
38 lines
428 B
PHP
38 lines
428 B
PHP
--TEST--
|
|
Bug #69180: Reflection does not honor trait conflict resolution / method aliasing
|
|
--FILE--
|
|
<?php
|
|
|
|
trait T1
|
|
{
|
|
public function foo()
|
|
{
|
|
}
|
|
}
|
|
|
|
trait T2
|
|
{
|
|
use T1 { foo as bar; }
|
|
|
|
public function foo()
|
|
{
|
|
}
|
|
}
|
|
|
|
|
|
class C
|
|
{
|
|
use T2;
|
|
}
|
|
|
|
$class = new ReflectionClass('C');
|
|
|
|
foreach ($class->getMethods() as $method) {
|
|
var_dump($method->getName());
|
|
}
|
|
|
|
?>
|
|
--EXPECT--
|
|
string(3) "foo"
|
|
string(3) "bar"
|