Edit report at https://bugs.php.net/bug.php?id=52504&edit=1
ID: 52504
Comment by: vitaly dot mukhin at gmail dot com
Reported by: robert dot de dot wilde at online dot nl
Summary: Support relative namespaces
Status: Not a bug
Type: Feature/Change Request
Package: Class/Object related
Operating System: Any
PHP Version: 5.3.3
Block user comment: N
Private report: N
New Comment:
Two cases:
namespace Language\Programming\Scripting;
{
class Php extends ..\Scripting
{}
}
VS
namespace Language\Programming\Scripting;
{
class Php extends \Language\Programming\Scripting
{}
}
This example, I suppose, covers a huge percentage of class extendings. And, as
you can see, first variant is much more easier and convenient in using.
Previous Comments:
------------------------------------------------------------------------
[2012-04-02 21:01:45] francescrosasbosque at gmail dot com
As I understand it accessing parent namespaces would require the same brain
power
that it needs to access child namespaces as both of them rely on knowing what's
the current namespace. To me it is weird to have one but not the other.
------------------------------------------------------------------------
[2012-02-28 10:38:59] [email protected]
Adding support for the ..\..\Foo\Bar notation quickly requires quite some brain
power to read the code, especially in a longer file where the namespace
declaration might not be on the same screen. We try to keep PHP code
human-readable.
Doing the use foo\*; thing is not possible due to PHP's dynamic nature. We do
not know which classes there might be (think __autoload) so we'd like to do it
but can't.
------------------------------------------------------------------------
[2012-02-26 10:10:33] tom at tomwardrop dot com
I was just about to post the exact same feature suggestion. I'm using PHP 5.4
RC8
after 2 years of programming Ruby (I have a project that better lends itself to
PHP template-orientated nature), and this was one of the first things I tried
to
do, reference a resource one level up in the namespace hierarchy. Luckily, my
namespace isn't too deep, but I can imagine some of the larger frameworks which
have 3-6+ level deep namespaces could really benefit from this.
I'm surprised none of the dev's have commented on this.
------------------------------------------------------------------------
[2010-08-18 15:44:12] robert dot de dot wilde at online dot nl
Any developer can have a look?
------------------------------------------------------------------------
[2010-07-31 10:54:14] giorgio dot liscio at email dot it
very nice, i really like it
it would be nice too having * on import
works only if __autoload or spl_autoload_register is used, otherwise triggers
an error
use MyNS\Test\*; // imports all classes in the "Test" namespace
use MyNS\Test\**; // imports all the namespace hierarchy (including
subpackages) from namespace Test
__autoload($className, $importAll = FALSE, $importDeep = FALSE)
{
// handle * as a full dir import
// ** imports subdirs too
}
in my framework i need to put
use \FW\String;
use \FW\Int;
use \FW\Float;
use \FW\Vector;
use \FW\Dictionary;
use \FW\Types;
etc in every file...
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=52504
--
Edit this bug report at https://bugs.php.net/bug.php?id=52504&edit=1