]> granicus.if.org Git - php/commitdiff
Allowed to override internal classaes with "use"
authorDmitry Stogov <dmitry@php.net>
Fri, 20 Jun 2008 17:17:19 +0000 (17:17 +0000)
committerDmitry Stogov <dmitry@php.net>
Fri, 20 Jun 2008 17:17:19 +0000 (17:17 +0000)
Zend/tests/ns_066.phpt [new file with mode: 0644]
Zend/tests/ns_067.inc [new file with mode: 0644]
Zend/tests/ns_067.phpt [new file with mode: 0644]
Zend/zend_compile.c

diff --git a/Zend/tests/ns_066.phpt b/Zend/tests/ns_066.phpt
new file mode 100644 (file)
index 0000000..3a7d9a5
--- /dev/null
@@ -0,0 +1,10 @@
+--TEST--
+066: Name ambiguity (import name & internal class name)
+--FILE--
+<?php
+include __DIR__ . '/ns_027.inc';
+use Foo::Bar::Foo as stdClass;
+
+new stdClass();
+--EXPECT--
+Foo::Bar::Foo
diff --git a/Zend/tests/ns_067.inc b/Zend/tests/ns_067.inc
new file mode 100644 (file)
index 0000000..09327b2
--- /dev/null
@@ -0,0 +1,3 @@
+<?php
+use Foo::Bar::Foo as Test;
+new Test();
diff --git a/Zend/tests/ns_067.phpt b/Zend/tests/ns_067.phpt
new file mode 100644 (file)
index 0000000..c509627
--- /dev/null
@@ -0,0 +1,9 @@
+--TEST--
+067: Name ambiguity (import name & internal class name)
+--FILE--
+<?php
+include __DIR__ . '/ns_022.inc';
+include __DIR__ . '/ns_027.inc';
+include __DIR__ . '/ns_067.inc';
+--EXPECT--
+Foo::Bar::Foo
index 173b3cc066968e34a8cbbe020be93dee5ca3cedb..7187f097f4bab91aec87cde313b832df2b9447c0 100644 (file)
@@ -5391,6 +5391,7 @@ void zend_do_use(znode *ns_name, znode *new_name, int is_global TSRMLS_DC) /* {{
        zstr lcname;
        zval *name, *ns, tmp;
        zend_bool warn = 0;
+       zend_class_entry **pce;
 
        if (!CG(current_import)) {
                CG(current_import) = emalloc(sizeof(HashTable));
@@ -5462,7 +5463,9 @@ void zend_do_use(znode *ns_name, znode *new_name, int is_global TSRMLS_DC) /* {{
                        efree(tmp.v);
                }
                efree(ns_name.v);
-       } else if (zend_u_hash_exists(CG(class_table), Z_TYPE_P(name), lcname, lcname_len+1)) {
+       } else if (zend_u_hash_find(CG(class_table), Z_TYPE_P(name), lcname, lcname_len+1, (void**)&pce) == SUCCESS &&
+                  (*pce)->type == ZEND_USER_CLASS &&
+                  (*pce)->filename == CG(compiled_filename)) {
                unsigned int tmp_len;           
                zstr tmp = zend_u_str_case_fold(Z_TYPE_P(ns), Z_UNIVAL_P(ns), Z_UNILEN_P(ns), 0, &tmp_len);