Re: [Coding Standards] (require|include)_once not allowed

From: Date: Mon, 09 Jul 2007 23:01:41 +0000
Subject: Re: [Coding Standards] (require|include)_once not allowed
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-47338@lists.php.net to get a copy of this message
Paul M Jones wrote:
The proposed standard states:
*_once including of files not allowed include/require/require_once/include_once is not allowed for loading class files except in the "load all classes for beginners" file. Instead, class_exists() with the optional second parameter should be used. Instead of:
While "phar" is wonderful, I am wary of writing a general coding standard with one particular tool in mind. This would be like saying "don't use function X because a particular IDE doesn't work well with it". I think this is related to allfiles.php
Can anyone here tell me why or how the class_exists() + throw() solution is a "more flexible choice" for class loading, so much so that require_once() should be prohibited? You can give nicer messages (like this file in in package blah, see faq x). It also makes pretty much all errors an exception. But i don't really think its worth the benefit.
This seems like another candidate for "recipe" or "practice" to me, not a rule by which package acceptance can be denied.
For sure on the second part. On the first that depends what we decide on file loading. -josh

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