Bug #79605 [Opn]: ReflectionMethod reports wrong name of aliased trait method used by a class
| From: | nikic@php.net | Date: | Fri, 15 May 2020 17:47:20 +0000 |
| Subject: | Bug #79605 [Opn]: ReflectionMethod reports wrong name of aliased trait method used by a class | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-227060@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79605&edit=1
ID: 79605
Updated by: nikic@php.net
Reported by: ondrej at mirtes dot cz
Summary: ReflectionMethod reports wrong name of aliased trait
method used by a class
Status: Open
Type: Bug
Package: Reflection related
Operating System: Any
PHP Version: 7.4.6
Block user comment: N
Private report: N
New Comment:
Duplicate of bug #69180, which is fixed in PHP 8.
Previous Comments:
------------------------------------------------------------------------
[2020-05-15 17:30:36] ondrej at mirtes dot cz
Description:
------------
ReflectionMethod reports wrong name of aliased trait method used by a class. I'd expect the
same name the ReflectionMethod was fetched as (parentFooMethod).
Test script:
---------------
<?php
trait BazTrait
{
public function fooMethod(): void
{
}
}
trait BarTrait
{
use BazTrait {
fooMethod as parentFooMethod;
}
public function fooMethod(): void
{
$this->fooMethod();
$this->parentFooMethod();
}
}
class Foo
{
use BarTrait;
public function doFoo(): void
{
$this->fooMethod();
$this->parentFooMethod();
}
}
$bar = new \ReflectionClass(BarTrait::class);
var_dump($bar->getMethod('parentFooMethod')->getName());
$foo = new \ReflectionClass(Foo::class);
var_dump($foo->hasMethod('parentFooMethod'));
var_dump($foo->getMethod('parentFooMethod')->getName());
Expected result:
----------------
string(15) "parentFooMethod"
bool(true)
string(9) "parentFooMethod"
Actual result:
--------------
string(15) "parentFooMethod"
bool(true)
string(9) "fooMethod"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79605&edit=1