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

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to