Re: __autoload proposal

From: Date: Sun, 23 Dec 2007 00:27:04 +0000
Subject: Re: __autoload proposal
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-34226@lists.php.net to get a copy of this message
On Dec 22, 2007 3:43 PM, Wojciech Malota <wojtekm86@konto.pl> wrote: > I have a proposal for prototype of __autoload function in PHP 5.3.0. > In this version of PHP namespaces will be available. > Prototype of __autoload could look like this: > > __autoload($classname, $namespace = null); > > Now __autoload have only one argument which is a name of searched class. > Second argument could be a namespace where class is searched. It should have > default value for backward compatibility. > > For example: > > <?php > namespace Space1::Space2; > class A { > public function Test() { > $b = new B; // Class B isn't known at this moment > } > } > ?> > > When user try to create new object of unknown class B __autoload function > should be called with parameter $classname = 'B' and $namespace = > 'Space1::Space2' > > but int this example: > > > <?php > namespace Space1::Space2; > class A { > public function Test() { > $b = new Space3::Space4::B; // Class B isn't known at this moment > } > } > ?> > > Arguments should be: $classname = 'B' and $namespace = 'Space3::Space4'; > > I think it is the most flexible solution. It allows to create very useful > and effective mapping mechanisms. > > -- > Wojciech Ma³ota > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > Patch ? -- David Coallier, Founder & Software Architect, Agora Production (http://agoraproduction.com) 51.42.06.70.18

« previous php.internals (#34226) next »