Re: PEAR-wide code quality issue (fix proposal for possible class redeclare errors)
| From: | Alan Knowles | Date: | Wed, 26 Jul 2006 01:00:47 +0000 |
| Subject: | Re: PEAR-wide code quality issue (fix proposal for possible class redeclare errors) | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-43572@lists.php.net to get a copy of this message | ||
In my view, the current behaviour is correct, It's a programmer error! - not an application error. -
The message is 'you've made a mistake - fix it!'
it's a bit like throwing an exception on a syntax error... - I know PHP's a bit loose there, but, allowing serious programming errors to be caught is a little ridiculous...
I've not seen one case where this is not a programmer mistake, but I'm alway open to being enlightened..
Regards
Alan
peter fiksman wrote:
Yes, an Exception is catchable so you can produce some better error than "fatal error". Furthermore, if Exception is carried along with the class def all that class_exists checks are not needed: the class definiton itself throws the Exception if loaded twice. Maybe it should even be the default PHP behaviour since PHP5 :)Well he seems to want an Exception, which is catchable. However instead of writing code to catch he should just do a class_exists() check before doing the require. regards, Lukas -- PEAR Development Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php----- Original Message ----- From: "Lukas Smith" <lsmith@php.net> To: "Matthew Weier O'Phinney" <mweierophinney@gmail.com> Cc: <pear-dev@lists.php.net> Sent: Tuesday, July 25, 2006 8:42 AM Subject: Re: [PEAR-DEV] PEAR-wide code quality issue (fix proposal for possible class redeclare errors)Because PHP already does this by throwing a fatal error. Why reinvent the wheel?why not throw an exception then, like: if (!class_exists(Class_Name)) { class Class_Name {Matthew Weier O'Phinney wrote:On 7/23/06, peter fiksman <pfiksman@gmx.net> wrote:Hello, still one question more on this topic:// class def goes here} } else { throw new Exception ("fatal error caught, redefining classname ... in ".__FILE__); }