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

From: Date: Sun, 23 Jul 2006 23:10:57 +0000
Subject: Re: PEAR-wide code quality issue (fix proposal for possible class redeclare errors)
References: 1 2 3 4 5  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-43552@lists.php.net to get a copy of this message
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__); } ----- Original Message ----- From: "Philippe Jausions" <Philippe.Jausions@11abacus.com> To: "peter fiksman" <pfiksman@gmx.net> Cc: "Pierre" <pierre.php@gmail.com>; <pear-dev@lists.php.net> Sent: Sunday, July 16, 2006 8:25 PM Subject: Re: [PEAR-DEV] PEAR-wide code quality issue (fix proposal for possible class redeclare errors) > peter fiksman wrote: > > Hello, > > > > well, if you use a system with highly dynamic or even self-learning path > > generation and discovery, the described situation with doubled require_once > > for the same file could become an unpredictable case. > > > > What are the real backdrawals of my proposal (to enclose class definitions > > into an if-clause, preventing fatal error on double definition if occured)? > > > > cheers, > > Peter > > > > The problem is that it causes more headaches then it solves. What if the > class name conflict is a real one: 2 different classes that have > actually the same name. By effectively silencing the fatal error, the > code will have a strange hard-to-detect behavior. > > That's why there are include_path, require_once and include_once. > > If you actually have some fatal errors like these, it means there is > something seriously wrong going on, and you should welcome such errors > as they help debug and make your application more reliable. > > -Philippe > > -- > PEAR Development Mailing List (http://pear.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

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