php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79636 ReflectionMethod returns wrong method name for aliases
Submitted: 2020-05-26 14:48 UTC Modified: 2020-05-26 15:16 UTC
From: david at grudl dot com Assigned:
Status: Duplicate Package: Reflection related
PHP Version: 7.4.6 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: david at grudl dot com
New email:
PHP Version: OS:

 

 [2020-05-26 14:48 UTC] david at grudl dot com
Description:
------------
Directly created object ReflectionMethod returns wrong method name when method is aliased. As opposite, ReflectionClass::getMethod() returns correct name.

It affects PHP since 5.4


https://3v4l.org/Nlm9C

Test script:
---------------
<?php

trait A
{
	function foo()
	{
	}
}

class C
{
	use A {
		A::foo as alias;
	}
}

$rm = new ReflectionMethod('C', 'alias');
echo $rm->name; // returns 'foo'
echo "\n";
echo (new ReflectionClass('C'))->getMethod('alias')->name; // returns 'alias'


Expected result:
----------------
Should return 'alias' in the both cases.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-05-26 15:09 UTC] david at grudl dot com
To clarify: the main problem is that in the class 'C' there can be also another and different method 'foo'.

https://3v4l.org/T79sZ
 [2020-05-26 15:16 UTC] nikic@php.net
-Status: Open +Status: Duplicate
 [2020-05-26 15:16 UTC] nikic@php.net
Duplicate of bug #69180, fixed in PHP 8.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Nov 27 18:01:29 2024 UTC