Req #66010 [Fbk->NoF]: "getClosure" should return methods of a given Trait
Edit report at https://bugs.php.net/bug.php?id=66010&edit=1
ID: 66010
Updated by: php-bugs@lists.php.net
Reported by: caiounif at gmail dot com
Summary: "getClosure" should return methods of a given Trait
-Status: Feedback
+Status: No Feedback
Type: Feature/Change Request
Package: Reflection related
Operating System: Ubuntu 13.10
PHP Version: 5.4.21
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2015-01-12 22:11:38] danack@php.net
Hi, it's unclear what you're trying to do. You say that you're trying to get the
methods of a trait through reflection - but your code is actually trying to create a closure, that
could be called.
That is not possible.....traits are only callable once they've been included in a class. It
would be a bit like trying to get a closure of an interface....until it's included inside a
class it just isn't a real thing that can be called.
Calling getMethods on the reflection for the trait does return all the information about a traits
methods. If you mean something else by "get its methods" please can you clarify.
------------------------------------------------------------------------
[2013-10-31 12:58:45] caiounif at gmail dot com
Description:
------------
Since Traits can't be instantiated, it is impossible to get its methods.
Test script:
---------------
trait foo {
protected $bar;
public function set_bar ($bar) {
$this->bar = $bar;
}
}
$reflection = new ReflectionClass ("foo");
print_r ($reflection->getMethods ()[0]->getClosure ());
Expected result:
----------------
Closure Object
(
[this] => EMPTY (WILD GUESS)
[parameter] => Array
(
[$bar] => <required>
)
)
Actual result:
--------------
PHP Warning: ReflectionMethod::getClosure() expects exactly 1 parameter, 0 given
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66010&edit=1
Thread (3 messages)