#49046 [Bgs->Asn]: namespaces with leading \ misbehave
| From: | derick@php.net | Date: | Fri, 24 Jul 2009 16:38:28 +0000 |
| Subject: | #49046 [Bgs->Asn]: namespaces with leading \ misbehave | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-140212@lists.php.net to get a copy of this message | ||
ID: 49046
Updated by: derick@php.net
Reported By: simon at stienen dot name
-Status: Bogus
+Status: Assigned
Bug Type: Scripting Engine problem
Operating System: FreeBSD
PHP Version: 5.3SVN-2009-07-24 (SVN)
-Assigned To:
+Assigned To: dmitry
New Comment:
Nonsense Jani, we allow more than on per file. Dmitry, could you please
have a look?
Previous Comments:
------------------------------------------------------------------------
[2009-07-24 15:32:54] jani@php.net
RTFM: http://www.php.net/manual/en/language.namespaces.definition.php
You can only have one namespace per file..
------------------------------------------------------------------------
[2009-07-24 13:18:46] simon at stienen dot name
Whyever this is necessary:
<?php
namespace Foo;
const Bar = "Blob";
namespace \Bar;
function x() { echo __NAMESPACE__; }
x();
?>
... happy now?)
------------------------------------------------------------------------
[2009-07-24 11:26:58] simon at stienen dot name
Description:
------------
So much wrong here ...
The initial intention was to get back into global namespace using the
"namespace X;" syntax. (Why isn't this possible? Neither as namespace;
namespace \; ... not even namespace \\;)
Curiously, "namespace \" expected the name of a constant.
Even more curiously, "namespace \foo" is looking for the constant "foo"
in the *current* namespace.
If the constant exists, the namespace directive is simply ignored.
If it does not, the script dies with a fatal error.
Reproduce code:
---------------
namespace Foo;
const Bar = "Blob";
namespace \Bar;
function x() { echo __NAMESPACE__; }
x();
Expected result:
----------------
Pretty much everything else than the actual result ... but at least
"Bar" or "Blob"
Actual result:
--------------
Foo
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49046&edit=1