Re: What are the problems PEAR2 seeks to solve? [and a solution to therequire_once debacle]

From: Date: Wed, 29 Aug 2007 06:06:24 +0000
Subject: Re: What are the problems PEAR2 seeks to solve? [and a solution to therequire_once debacle]
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-47891@lists.php.net to get a copy of this message
Gregory Beaver wrote: > > It must be noted that the addition of namespaces changes a great deal. There is an uncommitted > patch on php-internals adding autoload support to namespaces which will change things quite a bit. > Because of that patch, using unqualified classnames no longer works with autoload if they share the > same name as an internal class (like Exception), which will happen with this code: > [snip] > > Suddenly, this doesn't look so different from: > > PEAR2/Package/Thing.php: > <?php > namespace PEAR2::Package; > require_once 'PEAR2/Package/Exception.php'; > class Thing > { > function __construct() > { > // this should load PEAR2::Package::Exception, but instead throws the built-in > Exception > throw new Exception('hi'); > } > } > ?> > > So perhaps by substituting the import statement for require_once, this will preserve the > readability and maintainability? It should be noted that for conflicting classnames, we can also > use: > > import PEAR2::OtherPackage::Exception as OException; > > and then use it freely in the file as "OException" > > I hope this document will help to settle some of the bad blood that has occurred on pear-dev. > I, and the entire PEAR Group, wish to apologize for any appearance of strong-arming, and hope that > with this message, the motives, the problems, and some of the potential solutions are better > understood. > > Thanks for your time and reading all the way to here. > Greg Just a quick note: I'd strongly suggest to not shortcut the namespaces or even use import at all in PEAR2, but always use fully qualified namespaces. It makes the code much clearer for debugging, and prevents WTF moments. -Philippe

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