Re: [Coding Standards] (require|include)_once not allowed
| From: | Matthew Weier O'Phinney | Date: | Tue, 10 Jul 2007 13:44:33 +0000 |
| Subject: | Re: [Coding Standards] (require|include)_once not allowed | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-47391@lists.php.net to get a copy of this message | ||
On 7/9/07, Joshua Eichorn <josh@bluga.net> wrote:
Paul M Jones wrote: The proposed standard states:On the other hand, using *standard* functionality has benefits in that most IDEs will see a "require_once" and be able to resolve that to a file when debugging.*_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.I think the standard PHP errors give plenty of clues in most cases; typically, the first thing I consider when I get a "class does not exist" error is to check the top of the file to see if the class file was actually included. That sort of practice is easy to put in an FAQ. -- Matthew Weier O'Phinney mweierophinney@gmail.com http://weierophinney.net/matthew/