Req #52504 [Com]: Support relative namespaces

From: Date: Sat, 31 Jul 2010 08:54:14 +0000
Subject: Req #52504 [Com]: Support relative namespaces
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-152994@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=52504&edit=1

 ID:                 52504
 Comment by:         giorgio dot liscio at email dot it
 Reported by:        robert dot de dot wilde at online dot nl
 Summary:            Support relative namespaces
 Status:             Open
 Type:               Feature/Change Request
 Package:            *Programming Data Structures
 Operating System:   Any
 PHP Version:        5.3.3
 Block user comment: N

 New Comment:

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...


Previous Comments:
------------------------------------------------------------------------
[2010-07-31 09:58:03] robert dot de dot wilde at online dot nl

Description:
------------
It would be nice to have relative namespace support to keep code clean
and flexible.

When inside of a namespace, it would be nice to have some
directory-path-like option like '..'.

Test script:
---------------
namespace MyNs\Some\Path\Going\A\Long\Way
{
  class GoClass extends ..\..\Short\Way\GoClass  // <<
  {}
}



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



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=52504&edit=1


Thread (13 messages)

« previous php.bugs (#152994) next »