diff --git a/Zend/tests/bug42859.phpt b/Zend/tests/bug42859.phpt index 755f41f8d62b9..18d686008dcac 100644 --- a/Zend/tests/bug42859.phpt +++ b/Zend/tests/bug42859.phpt @@ -6,7 +6,8 @@ namespace Foo; class Ex {} use Blah\Exception; -use Blah\Ex; +var_dump(new Ex); ?> --EXPECTF-- -Fatal error: Cannot use Blah\Ex as Ex because the name is already in use in %sbug42859.php on line 6 +object(Foo\Ex)#%d (0) { +} diff --git a/Zend/tests/ns_030.phpt b/Zend/tests/ns_030.phpt index 69724159eedb6..a6ea651f92f56 100644 --- a/Zend/tests/ns_030.phpt +++ b/Zend/tests/ns_030.phpt @@ -9,4 +9,4 @@ use A\B as Foo; new Foo(); --EXPECTF-- -Fatal error: Cannot use A\B as Foo because the name is already in use in %sns_030.php on line 5 +Fatal error: Class 'A\B' not found in %s on line %d diff --git a/Zend/tests/use_const/define_imported_before.phpt b/Zend/tests/use_const/define_imported_before.phpt index f674ce81e8ec2..7b3fda799da3e 100644 --- a/Zend/tests/use_const/define_imported_before.phpt +++ b/Zend/tests/use_const/define_imported_before.phpt @@ -7,12 +7,10 @@ namespace { const bar = 42; use const foo\bar; -} -namespace { - echo "Done"; + echo bar; } ?> --EXPECTF-- -Fatal error: Cannot use const foo\bar as bar because the name is already in use in %s on line %d +Fatal error: Undefined constant 'foo\bar' in %s on line %d diff --git a/Zend/tests/use_function/define_imported_before.phpt b/Zend/tests/use_function/define_imported_before.phpt index 91974e0783d15..2cfdd981c048d 100644 --- a/Zend/tests/use_function/define_imported_before.phpt +++ b/Zend/tests/use_function/define_imported_before.phpt @@ -7,12 +7,10 @@ namespace { function bar() {} use function foo\bar; -} -namespace { - echo "Done"; + bar(); } ?> --EXPECTF-- -Fatal error: Cannot use function foo\bar as bar because the name is already in use in %s on line %d +Fatal error: Call to undefined function foo\bar() in %s on line %d diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 6321983a20d51..bce3ffe7f5b1c 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -4924,17 +4924,6 @@ static char *zend_get_use_type_str(uint32_t type) /* {{{ */ } /* }}} */ -static void zend_check_already_in_use(uint32_t type, zend_string *old_name, zend_string *new_name, zend_string *check_name) /* {{{ */ -{ - if (zend_string_equals_ci(old_name, check_name)) { - return; - } - - zend_error_noreturn(E_COMPILE_ERROR, "Cannot use%s %s as %s because the name " - "is already in use", zend_get_use_type_str(type), old_name->val, new_name->val); -} -/* }}} */ - void zend_compile_use(zend_ast *ast) /* {{{ */ { zend_ast_list *list = zend_ast_get_list(ast); @@ -4987,51 +4976,6 @@ void zend_compile_use(zend_ast *ast) /* {{{ */ "is a special class name", old_name->val, new_name->val, new_name->val); } - if (current_ns) { - zend_string *ns_name = zend_string_alloc(current_ns->len + 1 + new_name->len, 0); - zend_str_tolower_copy(ns_name->val, current_ns->val, current_ns->len); - ns_name->val[current_ns->len] = '\\'; - memcpy(ns_name->val + current_ns->len + 1, lookup_name->val, lookup_name->len); - - if (zend_hash_exists(CG(class_table), ns_name)) { - zend_check_already_in_use(type, old_name, new_name, ns_name); - } - - zend_string_free(ns_name); - } else { - switch (type) { - case T_CLASS: - { - zend_class_entry *ce = zend_hash_find_ptr(CG(class_table), lookup_name); - if (ce && ce->type == ZEND_USER_CLASS - && ce->info.user.filename == CG(compiled_filename) - ) { - zend_check_already_in_use(type, old_name, new_name, lookup_name); - } - break; - } - case T_FUNCTION: - { - zend_function *fn = zend_hash_find_ptr(CG(function_table), lookup_name); - if (fn && fn->type == ZEND_USER_FUNCTION - && fn->op_array.filename == CG(compiled_filename) - ) { - zend_check_already_in_use(type, old_name, new_name, lookup_name); - } - break; - } - case T_CONST: - { - zend_string *filename = zend_hash_find_ptr(&CG(const_filenames), lookup_name); - if (filename && filename == CG(compiled_filename)) { - zend_check_already_in_use(type, old_name, new_name, lookup_name); - } - break; - } - EMPTY_SWITCH_DEFAULT_CASE() - } - } - zend_string_addref(old_name); if (!zend_hash_add_ptr(current_import, lookup_name, old_name)) { zend_error_noreturn(E_COMPILE_ERROR, "Cannot use%s %s as %s because the name "