#46304 [Opn->Bgs]: definening namespaced constant using define() defines CASE SENSITIVE namespace
| From: | felipe@php.net | Date: | Wed, 15 Oct 2008 15:57:01 +0000 |
| Subject: | #46304 [Opn->Bgs]: definening namespaced constant using define() defines CASE SENSITIVE namespace | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-129727@lists.php.net to get a copy of this message | ||
ID: 46304
Updated by: felipe@php.net
Reported By: kenashkov at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: GNU/Linux debian lenny
PHP Version: 5.3CVS-2008-10-15 (snap)
New Comment:
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
The define() works in runtime.
Previous Comments:
------------------------------------------------------------------------
[2008-10-15 15:39:29] kenashkov at gmail dot com
<?
namespace NS1::ns2;
const const2 = 'value2';
define('NS1::ns2::const1','value');
$dc = get_defined_constants(true);
print '<pre>'.print_r($dc['user'],true).'</pre>';
?>
gives
Array
(
[ns1::ns2::const2] => value2
[NS1::ns2::const1] => value
)
------------------------------------------------------------------------
[2008-10-15 15:36:32] kenashkov at gmail dot com
changed summary
------------------------------------------------------------------------
[2008-10-15 15:33:34] kenashkov at gmail dot com
I had a quick look again over the docs and nowhere is documented that
the namespaces are case insensitive. I think this should go in the docs,
as well if this issue with define() wont be fixed, to be documented too.
------------------------------------------------------------------------
[2008-10-15 15:29:42] kenashkov at gmail dot com
Description:
------------
The current implementatino of namespaces is case INSENSITIVE. But
defining a constant using define and having capitals in the namespace
makes the defined constant unreachable.
We can verify this using get_defined_constants(). In case a constant
was defined like:
<?
namespace NS1::ns2;
const const1;
?>
we can see the the defined constant/namespace is in fact:
ns1::ns2::const1;
But if the constant was defined using define(), it is kept with the
capitalization:
<?
define('NS1::ns2::const1','value');
?>
get_defined_constants() gives NS1::ns2::const1.
But because the namespaces are case insensitive the call:
<?
print NS1::ns2::const1;
?>
resolves in fact to ns1::ns2::const1 which is undefined.
Reproduce code:
---------------
<?
define('NS1::ns2::const1','value');
print NS1::ns2::const1;//error
//print ns1::ns2::const1;//would give error too
?>
Expected result:
----------------
value
Actual result:
--------------
Fatal error: Class 'NS1::ns2' not found in /home/local/tests/t35.php on
line 3
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=46304&edit=1