Bug->Req #64963 [Opn]: ReflectionClass::getMethods does not identify traits
| From: | nikic@php.net | Date: | Mon, 02 Mar 2020 12:26:45 +0000 |
| Subject: | Bug->Req #64963 [Opn]: ReflectionClass::getMethods does not identify traits | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-225839@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=64963&edit=1
ID: 64963
Updated by: nikic@php.net
Reported by: alasdair at softhome dot net
Summary: ReflectionClass::getMethods does not identify traits
Status: Open
-Type: Bug
+Type: Feature/Change Request
Package: Reflection related
Operating System: Debian Wheezy
PHP Version: 5.4.15
Block user comment: N
Private report: N
New Comment:
Reclassifying as feature request for a new method to provide the trait prototype method. The current
behavior of getDeclaringClass() is correct, but there is space for an additional API here.
Previous Comments:
------------------------------------------------------------------------
[2018-07-30 16:55:19] josef dot sabl at gmail dot com
This bug affects Nette Frameworks DI as well (as described here https://github.com/nette/di/issues/169) This
surely needs to be fixed. The argument that Trais are copied into classes so this is okay is very
weak imho.
------------------------------------------------------------------------
[2017-01-24 18:44:39] love at sickpeople dot se
FWIW, since the trait methods are copied, it is essentially declared by both parties.
------------------------------------------------------------------------
[2017-01-24 18:43:04] love at sickpeople dot se
I get that changing getDeclaringClass() will generate some discussion.
What about adding getDeclaringTrait()?
------------------------------------------------------------------------
[2016-06-18 12:38:05] cmb@php.net
Related To: Bug #68742
------------------------------------------------------------------------
[2014-10-01 22:12:58] ocramius at gmail dot com
Note that this also affects various codegen components: the problem is that a trait does not
actually exist unless used inside the context of a class.
Methods and members of the trait that were copied into the class context at eval-time should be
reflected as members of the class, not of the trait: same goes for the names of the methods, which
are the final ones (after eventual aliasing).
Information about the trait itself is pretty much useless except for libraries that extract method
body/file information: these could probably need a different API.
Related:
- https://github.com/zendframework/zf2/issues/6620
- https://github.com/Ocramius/ProxyManager/issues/147
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=64963
--
Edit this bug report at https://bugs.php.net/bug.php?id=64963&edit=1