Re: ReflectionClass::getMethod()
| From: | Sebastian Bergmann | Date: | Thu, 23 Dec 2004 06:43:16 +0000 |
| Subject: | Re: ReflectionClass::getMethod() | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-14186@lists.php.net to get a copy of this message | ||
Andi Gutmans wrote:
> Exceptions should be thrown for errors.
And trying to get a method that does not exist is an error.
> Can anyone shed some light on this? Why was this changed?
To make consistent use of ReflectionException, IIRC.
For instance, the following code
<?php
$method = new ReflectionMethod(
'NotExistingClass',
'notExistingMethod'
);
?>
throws an ReflectionException as well. Now one could argue that there
is no other way to signal an error in the __construct() than to use
methods, but I think it is better to use the same error signalling in
bith ReflectionClass::getMethod() and ReflectionMethod::__construct().
And besides, it is what Java does [1], so we cannot be that far off :-)
Seasons's Greetings,
Sebastian
--
[1] http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html
--
Sebastian Bergmann http://www.sebastian-bergmann.de/
GnuPG Key: 0xB85B5D69 / 27A7 2B14 09E4 98CD 6277 0E5B 6867 C514 B85B 5D69