#22395 [Asn->WFx]: Namespaces overwrite preexisting namespaces
| From: | sterling@php.net | Date: | Tue, 03 Jun 2003 20:57:23 +0000 |
| Subject: | #22395 [Asn->WFx]: Namespaces overwrite preexisting namespaces | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-41068@lists.php.net to get a copy of this message | ||
ID: 22395
Updated by: sterling@php.net
Reported By: andrew at evilwalrus dot com
-Status: Assigned
+Status: Wont fix
Bug Type: Zend Engine 2 problem
Operating System: WinXP
PHP Version: 5CVS-2003-02-24 (dev)
Assigned To: zeev
New Comment:
Namespaces no longer supported, not a bug anymore. :)
Previous Comments:
------------------------------------------------------------------------
[2003-04-18 18:25:00] thekid at thekid dot de
This can be fixed with this small extra check:
Index: Zend/zend_compile.c
===================================================================
RCS file: /repository/ZendEngine2/zend_compile.c,v
retrieving revision 1.412
diff -u -r1.412 zend_compile.c
--- Zend/zend_compile.c 11 Apr 2003 17:30:41 -0000 1.412
+++ Zend/zend_compile.c 18 Apr 2003 23:24:12 -0000
@@ -3417,6 +3417,10 @@
zend_op *opline;
zend_str_tolower(ns_name->u.constant.value.str.val,
ns_name->u.constant.value.str.len);
+ if (!(strcmp(ns_name->u.constant.value.str.val, "main") &&
strcmp(ns_name->u.constant.value.str.val, "self") &&
+ strcmp(ns_name->u.constant.value.str.val, "parent"))) {
+ zend_error(E_COMPILE_ERROR, "Cannot use '%s' as namespace name as it
is reserved", ns_name->u.constant.value.str.val);
+ }
if(zend_hash_find(&CG(global_namespace).class_table,
ns_name->u.constant.value.str.val, ns_name->u.constant.value.str.len+1,
(void **)&pns) == SUCCESS) {
ns = *pns;
------------------------------------------------------------------------
[2003-02-24 11:06:20] wez@php.net
Assigning to Zeev so that this doesn't get lost.
------------------------------------------------------------------------
[2003-02-24 10:02:58] andrew at evilwalrus dot com
The following code should (theoretically) generate a fatal error, as it
overwrites a predefined namespace (tested on 'parent' and 'self'
namespaces:
<?php
namespace parent
{
class foo
{
private $data;
function __construct($data)
{
$this->data = $data;
}
function debug()
{
print $this->data;
}
}
}
$foo = new parent::foo('Hello World!');
$foo->debug();
?>
----------------------------------------------------
I don't think this is done by design due to the fact that the
predefined namespaces are in place to prevent this, and also for other
uses.
~ Andrew Heebner
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=22395&edit=1