Re: PEAR-wide code quality issue (fix proposal for possible class redeclare errors)

From: Date: Tue, 25 Jul 2006 11:06:15 +0000
Subject: Re: PEAR-wide code quality issue (fix proposal for possible class redeclare errors)
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-43565@lists.php.net to get a copy of this message
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 :) > > ----- 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) > > > > Matthew Weier O'Phinney wrote: > > > On 7/23/06, peter fiksman <pfiksman@gmx.net> wrote: > > >> Hello, still one question more on this topic: > > >> > > >> why not throw an exception then, like: > > >> > > >> if (!class_exists(Class_Name)) > > >> { > > >> class Class_Name > > >> > > >> { > > >> // class def goes here > > >> } > > >> > > >> } > > >> else > > >> { > > >> > > >> throw new Exception ("fatal error caught, redefining classname ... in > > >> ".__FILE__); > > >> > > >> } > > > > > > Because PHP already does this by throwing a fatal error. Why reinvent > > > the wheel? > > > > 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 > > >

« previous php.pear.dev (#43565) next »