Bart de Boer schrieb: > namespace JessieStuff { > class FirstClass { ... } > class SecondClass { > public $obj; > function __construct() { > $this->obj = new FirstClass(); > } > } > } > > Now we'd import this with prefixing everything and the > result would be something that acts like: > > class JessieStuff_FirstClass { ... } > class JessieStuff_SecondClass { > public $obj; > function __construct() { > $this->obj = new FirstClass(); > } > } > > Then, if I do: > $x = new JessieStuff_SecondClass(); > > I'd get an error that 'FirstClass' can't be found. Because it's > renamed to JessieStuff_FirstClass.
Nope. First of all, using FirstClass INSIDE the namespace would always prefer using the own namespace. Local definitions override global definitions (see http://en.wikipedia.org/wiki/XML_namespace ). And then, the class is hopefully NOT renamed but aliased: namespace a { class A1 {} class A2 { protected $m=null; protected $n=null; public function __construct() { // should both work $this->m=new A1(); $this->m=new a:::A1(); } } } $x=new a:::A2(); import namespace a; $y=new A2(); // should work after import import a:::A2 as Foo; $z=new Foo(); // should work, A2 locally knows A1 $yikes=new a_A2(); // should work with auto_import_prefix set to on > Or do you suggest we replace all occurences of 'new ClassName()' to > 'new JessieStuff_ClassName()' as well? Occurences where? > Or do you suggest that everything that was inside the namespace is > still able to call "internal" classes without using the namespace > prefix? And your INI option only provides interface classes? This is part of the definition of namespaces. And yes, I want the INI option to just provide aliases. If these are implemented by injecting class a_A2 extends a::A2 {} as interface classes or by internally providing a hash table alias is only different from a technical point of view. The result would be the same, the performance would probably better using the alias. OLLi -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php