Allowed to override internal classaes with "use"

This commit is contained in:
Dmitry Stogov 2008-06-20 17:17:19 +00:00
parent 59b026dd1f
commit ecf108e681
4 changed files with 26 additions and 1 deletions

10
Zend/tests/ns_066.phpt Normal file
View File

@ -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

3
Zend/tests/ns_067.inc Normal file
View File

@ -0,0 +1,3 @@
<?php
use Foo::Bar::Foo as Test;
new Test();

9
Zend/tests/ns_067.phpt Normal file
View File

@ -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

View 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);