Suppose there is a class Mysql which must be in the space of lib

And library classes with Engine that live in engine space

Suppose I want to write humanly without using thousands of use declarations and not accessing classes через\нескончаемые\вагоны\пространства\имен

Now we need to do something like that

 namespace lib; use engine\Engine as Engine; use engine\Library as Library; class Mysql extends Library { public function Init() { Engine::Say('Test'); } } 

Is it possible to do something like this?

 namespace lib; use engine; // Вжух, и все пространство имен "распаковано" сюда class Mysql extends Library { public function Init() { Engine::Say('Test'); } } 

Or so?

 use engine; // Вжух, и все пространство имен "распаковано" сюда // Говорим, что Mysql теперь в lib без всяких namespace class lib\Mysql extends Library { public function Init() { Engine::Say('Test'); } } 

Who else avoids all this cereal at all?

  • in php7, you can write like this: use engine\ { Engine, Library, someAnotherClass, EtcClass }; - Alexey Shimansky

1 answer 1

You can't do that right, but you can have a short alias:

 namespace lib; use engine as E; // Вжух, и все пространство имен "распаковано" сюда class Mysql extends E\Library { public function Init() { E\Engine::Say('Test'); } }