mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Allow aliasing namespaces containing reserved class names
This reverts commit b9f7123c5e
.
Fixes GH-11152
Closes GH-11153
This commit is contained in:
parent
de9b3f648c
commit
5ad6571a21
4 changed files with 24 additions and 16 deletions
4
NEWS
4
NEWS
|
@ -2,6 +2,10 @@ PHP NEWS
|
|||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
?? ??? ????, PHP 8.2.7
|
||||
|
||||
- Core:
|
||||
. Fixed bug GH-11152 (Unable to alias namespaces containing reserved class
|
||||
names). (ilutov)
|
||||
|
||||
- Opcache:
|
||||
. Fixed bug GH-11134 (Incorrect match default branch optimization). (ilutov)
|
||||
|
||||
|
|
20
Zend/tests/gh11152.phpt
Normal file
20
Zend/tests/gh11152.phpt
Normal file
|
@ -0,0 +1,20 @@
|
|||
--TEST--
|
||||
GH-11152: Allow aliasing namespaces containing reserved class names
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
namespace string;
|
||||
|
||||
use string as StringAlias;
|
||||
|
||||
class C {}
|
||||
|
||||
function test(StringAlias\C $o) {
|
||||
var_dump($o::class);
|
||||
}
|
||||
|
||||
test(new C());
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
string(8) "string\C"
|
|
@ -1,10 +0,0 @@
|
|||
--TEST--
|
||||
Aliasing built-in types
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
use bool as A;
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Cannot alias 'bool' as it is a built-in type in %s on line %d
|
|
@ -8124,12 +8124,6 @@ static void zend_compile_use(zend_ast *ast) /* {{{ */
|
|||
zend_string *old_name = zend_ast_get_str(old_name_ast);
|
||||
zend_string *new_name, *lookup_name;
|
||||
|
||||
/* Check that we are not attempting to alias a built-in type */
|
||||
if (type == ZEND_SYMBOL_CLASS && zend_is_reserved_class_name(old_name)) {
|
||||
zend_error_noreturn(E_COMPILE_ERROR,
|
||||
"Cannot alias '%s' as it is a built-in type", ZSTR_VAL(old_name));
|
||||
}
|
||||
|
||||
if (new_name_ast) {
|
||||
new_name = zend_string_copy(zend_ast_get_str(new_name_ast));
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue