#40223 [Opn]: ReflectionMethod is not an subclass of ReflectionFunction
| From: | helly@php.net | Date: | Wed, 24 Jan 2007 20:23:51 +0000 |
| Subject: | #40223 [Opn]: ReflectionMethod is not an subclass of ReflectionFunction | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969375022@lists.php.net to get a copy of this message | ||
ID: 40223
Updated by: helly@php.net
Reported By: baldurien at bbnwn dot eu
Status: Open
Bug Type: Documentation problem
-Operating System: Windows XP SP2
+Operating System: *
-PHP Version: 5.2.0
+PHP Version: *
New Comment:
Method and Functions are in no way derived. Thus the following design
approach was taken:
class ReflectionMethod extends ReflectionFunctionAbstract implements
Reflector
class ReflectionFunction extends ReflectionFunctionAbstract implements
Reflector
Previous Comments:
------------------------------------------------------------------------
[2007-01-24 19:47:02] tony2001@php.net
The documentation is wrong, both ReflectionMethod & ReflectionFunction
extend abstract class called "ReflectionFunctionAbstract".
------------------------------------------------------------------------
[2007-01-24 19:46:19] bjori@php.net
(reclassified as documentation problem)
The docs are wrong (and really outdated).
ReflectionMethod and ReflectionFunction both extend
ReflectionFunctionAbstract.
(see: php --rc ReflectionMethod && php --rc
ReflectionFunction or php --re reflection)
------------------------------------------------------------------------
[2007-01-24 19:39:00] baldurien at bbnwn dot eu
Description:
------------
The doc (http://fr.php.net/manual/en/language.oop5.reflection.php)
state that ReflectioMethod be a ReflectionFunction.
class ReflectionFunction implements Reflector { }
class ReflectionMethod extends ReflectionFunction { }
But this is not how it works in PHP : when using type hinting, any
ReflectionMethod passed to a function or method that expect a
ReflectionFunction fails instead of working like with normal type
hinting.
Reproduce code:
---------------
class Foo {
public function bar(ReflectionFunction $fct) {
...
}
}
$c = new ReflectionClass('Foo');
$foo = new Foo();
$foo->bar($c->getMethod('bar'));
Expected result:
----------------
This should work because ReflectionMethod is a sub class of a
ReflectionFunction, and type hinting normally allows such thing (or the
documentation
[http://fr.php.net/manual/en/language.oop5.typehinting.php] should say
it clearly...)
Actual result:
--------------
[E_RECOVERABLE_ERROR] Argument 1 passed to Foo::bar() must be an
instance of ReflectionFunction, instance of ReflectionMethod given,
called in ... on line ... and defined' in ...
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=40223&edit=1