Tobias Schlitt wrote:
Hi Johannes Schlueter!
On 08/08/05 14:50 you wrote:
The throw an Exception when SPL disabled and an InvalidArgumentException
when it is enabled.
That's senseless when writing applications that shall be version
independant. Just sticking to Exception should be fine.
No it is not, in your application you can still simply catch Exception to be
independent of SPL since the InvalidArgumentException class extends the
Exception class. But by using nested Exceptions you can catch them
independently. Else you would have to catch every Exception, parse the error
message or trace to see wether it was a problem while calling the
function/method or some code inside the function/method went wrong.
The point is, that it's senseless to have it throw any exception that
can be disabled, when you want to write portable applications. In that
case you still have to stick to catch Exception and have no benefit of
it throwing anything else, when SPL is enabled.
I would pretty much appreciate it having thrown an
InvalidArgumentException, but then this should work everywhere.
I guess creating a new special exception (e.g. TypeHintException) that
extends Exception as part of the php core (as opposed to living in SPL)
is a stupid idea?
IMHO btw, semantically, calling it S(tandard)PL and then making it so that
it's not standard (i.e. it's an extension) seems odd.
Regards,
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php