mirror of
https://github.com/php/php-src.git
synced 2024-12-12 19:33:31 +08:00
Allowed to override internal classaes with "use"
This commit is contained in:
parent
59b026dd1f
commit
ecf108e681
10
Zend/tests/ns_066.phpt
Normal file
10
Zend/tests/ns_066.phpt
Normal 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
3
Zend/tests/ns_067.inc
Normal file
@ -0,0 +1,3 @@
|
||||
<?php
|
||||
use Foo::Bar::Foo as Test;
|
||||
new Test();
|
9
Zend/tests/ns_067.phpt
Normal file
9
Zend/tests/ns_067.phpt
Normal 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
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user