Sebastian,
I don't feel like arguing about it because hasMethod() is good enough for me.
Look at the attached example. It should make you understand why throwing an exception *without* having something like hasMethod() is very inefficient. Exceptions should be used for error situations. If a reflection API does not support hasMethod() then it should give an efficient way to get the method without throwing an inefficient exception.
This is real life usage for implementing delegation. Not some "well Java throws exceptions" explanation.
Anyway, as I said, I saw hasMethod() got commited which is good enough for me.
Andi
At 11:31 AM 12/25/2004 +0100, Sebastian Bergmann wrote:
[EMAIL PROTECTED] 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
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php