Bug->Req #54438 [Opn->Bgs]: use statement overwrite aliased namespace against using multiple
| From: | felipe@php.net | Date: | Sat, 02 Apr 2011 17:06:09 +0000 |
| Subject: | Bug->Req #54438 [Opn->Bgs]: use statement overwrite aliased namespace against using multiple | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-159914@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=54438&edit=1
ID: 54438
Updated by: felipe@php.net
Reported by: michal dot brzuchalski at gmail dot com
Summary: use statement overwrite aliased namespace against
using multiple
-Status: Open
+Status: Bogus
-Type: Bug
+Type: Feature/Change Request
Package: Class/Object related
Operating System: Linux
PHP Version: 5.3.6
Block user comment: N
Private report: N
New Comment:
This is not a bug. It works as expected, an alias cannot be used for
more than one class/namespace/...
Previous Comments:
------------------------------------------------------------------------
[2011-04-01 10:09:34] michal dot brzuchalski at gmail dot com
Description:
------------
In use statement we can use "," to separate aliased namespaces but the
alias only affect to the last one declared use namespace. It'll be
logical to use all declared namespaces in alias and use
classes/constants/closures/etc. from aliased namespace where they
exists.
Test script:
---------------
<?
namespace A;
class test1 {}
class test2 {}
namespace B;
class test1 {}
use A, B as Foo;
$test1 = new Foo\test1;
echo get_class($test1). "\n";
$test2 = new Foo\test2;
echo get_class($test2). "\n";
Expected result:
----------------
B\test1
A\test2
Actual result:
--------------
B\test1
PHP Fatal error: Class 'B\test2' not found in test.php on line 13
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=54438&edit=1