Bug #64963 [Com]: ReflectionClass::getMethods does not identify traits
| From: | ocramius at gmail dot com | Date: | Wed, 01 Oct 2014 22:12:59 +0000 |
| Subject: | Bug #64963 [Com]: ReflectionClass::getMethods does not identify traits | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-187787@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
Comment by: ocramius at gmail dot com
Reported by: alasdair at softhome dot net
Summary: ReflectionClass::getMethods does not identify traits
Status: Open
Type: Bug
Package: Reflection related
Operating System: Debian Wheezy
PHP Version: 5.4.15
Block user comment: N
Private report: N
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[2013-10-15 17:14:20] nikic@php.net
The No-Feedback was an automated status change. I reverted the bug back to Open ;)
------------------------------------------------------------------------
[2013-10-15 13:05:39] alasdair at softhome dot net
Myself and david at mouf-php dot com still feel there is an issue here as I'm sure many other
people do as well.
Yes, David has provided a hacky workaround however this is not the solution.
The reason I had not added any more feedback was because I had just abandoned my use of traits due
to this behavior, not because the issue had been resolved/
------------------------------------------------------------------------
[2013-10-15 11:54:44] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
------------------------------------------------------------------------
[2013-06-27 09:58:04] alasdair at softhome dot net
Nice blog David. Good to see other people battling with this frustration as well. Will be looking
more indepth at your work around to see if it helps what I was planning on doing.
------------------------------------------------------------------------
[2013-06-27 08:46:27] david at mouf-php dot com
I have a very strong feeling about this.
I understand that the PHP implementation of traits is about copying traits into classes. Yet, the
whole purpose of a Reflection API is to find where properties / methods are declared.
I have a simple question: I need to be able to find in which class/trait a method is declared. I
need this for my PHP framework (Mouf), that is heavily relying in reflection to build a graphical
dependency injection system.
I've written a lengthy blog post explaining what the problems with the current Reflection API
are, and hopefully, how to find a (not perfect) work around.
You can find the blog post here: http://mouf-php.com/blog/php_reflection_api_traits
I really hope we can agree this is indeed something that needs to be fixed, as the workaround
I've put in place are far from perfect.
For technical details, my PHP version: PHP 5.4.9-4ubuntu2.1.
------------------------------------------------------------------------
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