Bug #71983 [Opn->Nab]: Not clear namespace resolution
| From: | cmb@php.net | Date: | Sat, 09 Apr 2016 11:25:59 +0000 |
| Subject: | Bug #71983 [Opn->Nab]: Not clear namespace resolution | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-200454@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=71983&edit=1
ID: 71983
Updated by: cmb@php.net
Reported by: goetas at gmail dot com
Summary: Not clear namespace resolution
-Status: Open
+Status: Not a bug
Type: Bug
Package: *General Issues
PHP Version: 5.6.20
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
The second namespace declaration already defines a class C in
namespace B, hence the error. You'd have to alias A\C, see
<https://3v4l.org/g90NX>, for instance.
Previous Comments:
------------------------------------------------------------------------
[2016-04-07 16:03:56] goetas at gmail dot com
Description:
------------
It is not possible to alias a class from a namespace.
I have also tried placing classes in different files, but the problem persists.
Test script:
---------------
<?php
namespace A {
class C {
}
}
namespace B {
class C {
}
}
namespace B {
use A\C;
echo "something";
}
Expected result:
----------------
something
Actual result:
--------------
PHP Fatal error: Cannot use A\C as C because the name is already in use in /vagrant/A/run.php on
line 12
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71983&edit=1