Re: ReflectionClass::getMethod()
| From: | Timm Friebe | Date: | Thu, 23 Dec 2004 00:06:01 +0000 |
| Subject: | Re: ReflectionClass::getMethod() | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-14174@lists.php.net to get a copy of this message | ||
On Wed, 2004-12-22 at 14:28 -0800, Andi Gutmans wrote:
> Hi,
>
> It seems that in the past few months ReflectionClass::getMethod() was
> changed to throw an Exception if the method doesn't exist.
-- snip --
revision 1.113
date: 2004/07/19 19:14:10; author: sebastian; state: Exp; lines: +9
-5
Make ReflectionClass::getMethod() and ReflectionClass::getProperty()
raise an ReflectionException instead of returning NULL on failure.
-- snip --
> I don't understand the reasoning because as it's a reflection API I
> would expect it to return false
NULL would be better, IMO, but nevertheless.
> and not an exception. Exceptions should be thrown for errors. As long
> as we don't have hasMethod() then I think this behavior is wrong.
Agreed.
> Can anyone shed some light on this? Why was this changed? Marcus?
Ask Sebastian:)
I think what Sebastian wanted to do is:
$reflectionClass->getMethod('abc')->invoke($object);
...and not have this bail with a fatal error when getMethod() returns
NULL, but raise an exception. Fine. I still think NULL->method() should
throw a NullPointerError instead of bailing but I also agree with Andi
that as long as there is no hasMethod() throwing an exception is
unacceptable.
--
Timm
If it ain't broken, it doesn't have enough features yet