This doesn't really clear it out. I can either use the "cleaner" method, and an exception would be raised when I'd try to call NULL(), or, have the OPTION to check whether it's NULL before calling it. IMHO It's much more consistent and clean.
You STILL can use exceptions the way you did, and in ADDITION you can write cleaner code which doesn't rely on exceptions. On Sat, 25 Dec 2004 11:31:58 +0100, Sebastian Bergmann <[EMAIL PROTECTED]> 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