Req #52504 [Com]: Support relative namespaces

From: Date: Tue, 11 Nov 2014 09:34:22 +0000
Subject: Req #52504 [Com]: Support relative namespaces
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-188558@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=52504&edit=1

 ID:                 52504
 Comment by:         andy at andyburton dot co dot uk
 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:

Agree this would be a nice addition.


Previous Comments:
------------------------------------------------------------------------
[2014-10-05 17:16:38] dodonnell at gmail dot com

Agreed that in my opinion ..\ does not require more brainpower. I think the syntax is pretty
self-explanatory to pretty much any one who knows some basic programming and, more importantly,
prevents having to use a lot of absolute namespacing that is sensitive to structural changes in a
project.

------------------------------------------------------------------------
[2013-11-05 18:50:47] mtdowling at gmail dot com

This feature request would allow libraries to be written in a way that they can be vendored inside
of other libraries without having to modify the library being vendored. Other languages, e.g.,
Python, allow this type of relative namespace traversal.

I don't agree that it would be hard to read or require "more brain power".

------------------------------------------------------------------------
[2013-03-19 12:01:32] vitaly dot mukhin at gmail dot com

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.

------------------------------------------------------------------------
[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] johannes@php.net

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.

------------------------------------------------------------------------


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


Thread (13 messages)

« previous php.bugs (#188558) next »