Skip to content

Commit 4f74e86

Browse files
committed
Merge branch 'PHP-8.2'
* PHP-8.2: Allow aliasing namespaces containing reserved class names
2 parents 4472443 + 5ad6571 commit 4f74e86

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

Zend/tests/gh11152.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
GH-11152: Allow aliasing namespaces containing reserved class names
3+
--FILE--
4+
<?php
5+
6+
namespace string;
7+
8+
use string as StringAlias;
9+
10+
class C {}
11+
12+
function test(StringAlias\C $o) {
13+
var_dump($o::class);
14+
}
15+
16+
test(new C());
17+
18+
?>
19+
--EXPECT--
20+
string(8) "string\C"

Zend/tests/use_statement/aliasing_builtin_types.phpt

Lines changed: 0 additions & 10 deletions
This file was deleted.

Zend/zend_compile.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8237,12 +8237,6 @@ static void zend_compile_use(zend_ast *ast) /* {{{ */
82378237
zend_string *old_name = zend_ast_get_str(old_name_ast);
82388238
zend_string *new_name, *lookup_name;
82398239

8240-
/* Check that we are not attempting to alias a built-in type */
8241-
if (type == ZEND_SYMBOL_CLASS && zend_is_reserved_class_name(old_name)) {
8242-
zend_error_noreturn(E_COMPILE_ERROR,
8243-
"Cannot alias '%s' as it is a built-in type", ZSTR_VAL(old_name));
8244-
}
8245-
82468240
if (new_name_ast) {
82478241
new_name = zend_string_copy(zend_ast_get_str(new_name_ast));
82488242
} else {

0 commit comments

Comments
 (0)