Bug #54105 [Opn->Bgs]: namespace names starting with \ should be invalid
Edit report at http://bugs.php.net/bug.php?id=54105&edit=1
ID: 54105
Updated by: felipe@php.net
Reported by: theseer@php.net
Summary: namespace names starting with \ should be invalid
-Status: Open
+Status: Bogus
Type: Bug
Package: Scripting Engine problem
Operating System: irrelevant
PHP Version: 5.3.5
Block user comment: N
Private report: N
New Comment:
'namespace \a;' is not declaring a namespace, but fetching a constant
'a' from the current namespace. (namespace\a)
http://docs.php.net/manual/en/language.namespaces.nsconstants.php
Previous Comments:
------------------------------------------------------------------------
[2011-02-26 14:13:24] johannes@php.net
Reading is hard ... seems valid
------------------------------------------------------------------------
[2011-02-26 14:00:01] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
define() does no checking of the name.
http://devzone.zend.com/article/475#Heading3
------------------------------------------------------------------------
[2011-02-26 13:45:24] theseer@php.net
Description:
------------
Defining a namespace who's name starts with a \ is interpreted as a
constant though resolving a constant for the namespace name is not
supported (and should not! :) ) and results in an empty string being
used.
Test script:
---------------
test.php:
<?php
define('a','\foo');
require 'a.php';
a.php:
<?php
namespace \a;
var_dump(__NAMESPACE__);
class b { }
Expected result:
----------------
(Parse?) Error due to invalid namespace definition
Actual result:
--------------
Empty string for __NAMESPACE__ or undefined constant a depending wheter
or not the file "a.php" got required or called directly
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=54105&edit=1
Thread (4 messages)