Re: ReflectionClass::getMethod()
| From: | Christian Schneider | Date: | Fri, 24 Dec 2004 14:21:05 +0000 |
| Subject: | Re: ReflectionClass::getMethod() | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-14202@lists.php.net to get a copy of this message | ||
Derick Rethans wrote:
I think it doesn't make sense if there is no method to actually check if it's there. Now you start throwing exeptions without having a way to avoid it. THAT is crazy.I assume that Sebastian would use something along the lines of try { $reflectionClass->getMethod("foo"); $hasmethod = true; } catch ($e) { $hasmethod = false; } to emulate hasMethod(). I agree with Andi and Derick that this is not the way an API should work. My main point is that 'basic' PHP APIs should avoid forcing users to use exceptions whenever possible. Converting traditional error handling to 'higher level' exceptions is easy: if (!$method = $reflectionClass->getMethod("foo")) throw new NoSuchMethodException; but the other direction is a) harder to read, b) requires knowledge about exceptions and c) slower. It also illustrates one of my pet peeves about exceptions: Nobody (not even the Java gods according to Sebastian's "it is what Java does [1], so we cannot be that far off") knows how to use exceptions properly (-:C - Chris