Re: ReflectionClass::getMethod()
| From: | Sebastian Bergmann | Date: | Sat, 25 Dec 2004 10:31:58 +0000 |
| Subject: | Re: ReflectionClass::getMethod() | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-14210@lists.php.net to get a copy of this message | ||
ilya77@gmail.com wrote:
> Why not just returning null when a method does not exist?
> Actually CALLING a non-existing method should be treated as an error...
Because
try {
$class = new ReflectionClass($this);
$method = $class->getMethod($this->name);
}
catch (ReflectionException $e) {
$this->fail($e->getMessage());
}
is clearer than
try {
$class = new ReflectionClass($this);
}
catch (ReflectionException $e) {
$this->fail($e->getMessage());
}
$method = $class->getMethod($this->name);
if ($method !== NULL) {
// ...
} else {
// ...
}
I fail to see why exceptions wee introduced when they are not to be
consistently used in functionality that was added at the same time, like
for instance the Reflection API.
--
Sebastian Bergmann http://www.sebastian-bergmann.de/
GnuPG Key: 0xB85B5D69 / 27A7 2B14 09E4 98CD 6277 0E5B 6867 C514 B85B 5D69