Req #60135 [Opn->Csd]: Request for mechanism to resolve namespace from alias
| From: | nikic@php.net | Date: | Sat, 11 Mar 2017 17:54:05 +0000 |
| Subject: | Req #60135 [Opn->Csd]: Request for mechanism to resolve namespace from alias | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-207786@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=60135&edit=1
ID: 60135
Updated by: nikic@php.net
Reported by: rev40oz at hotmail dot com
Summary: Request for mechanism to resolve namespace from
alias
-Status: Open
+Status: Closed
Type: Feature/Change Request
Package: Reflection related
Operating System: All
PHP Version: 5.3.8
-Assigned To:
+Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
I'm closing this as the primary use-case should be addressed by the ::class feature introduced
in PHP 5.5. You can pass ABC::class to your factory and it will resolve to a class name string based
on the class alias table.
Implementing a function such as resolve_namespace_alias() is not possible, because aliases are
per-file -- aliases in the file where the factory is implemented and where it is used may be
different.
Previous Comments:
------------------------------------------------------------------------
[2011-10-25 23:32:36] rev40oz at hotmail dot com
Description:
------------
I would like to request a feature for namespacing in future versions. From what
I can tell, there is currently no way to resolve the full namespace from a
namespace alias. Something along the lines of:
namespace a\b\c as ABC;
echo resolve_namespace_alias(ABC); // prints 'a\b\c'
Situations where class names are passed by string (factories) and need full
qualification can't currently benefit from NS aliasing in an elegant way.
Thanks,
Chuck Reed
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60135&edit=1