diff --git a/NEWS b/NEWS index c59c9a967c40e..a833bf4355ede 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,10 @@ PHP NEWS - COM: . Fix property access of PHP objects wrapped in variant. (cmb) +- Core: + . Fixed bug GH-16665 (\array and \callable should not be usable in + class_alias). (nielsdos) + - Curl: . Added curl_multi_get_handles(). (timwolla) diff --git a/UPGRADING b/UPGRADING index a336173ffd8b0..13e834f2610a3 100644 --- a/UPGRADING +++ b/UPGRADING @@ -25,6 +25,10 @@ PHP 8.5 UPGRADE NOTES . bzcompress() now throws a ValueError when $work_factor is not between 0 and 250. +- Core: + . It is no longer possible to use "array" and "callable" as class alias names + in class_alias(). + - LDAP: . ldap_get_option() and ldap_set_option() now throw a ValueError when passing an invalid option. diff --git a/Zend/tests/gh16665_1.phpt b/Zend/tests/gh16665_1.phpt new file mode 100644 index 0000000000000..5baa46a039121 --- /dev/null +++ b/Zend/tests/gh16665_1.phpt @@ -0,0 +1,8 @@ +--TEST-- +GH-16665 (\array should not be usable) +--FILE-- + +--EXPECTF-- +Fatal error: Cannot use "array" as a class alias as it is reserved in %s on line %d diff --git a/Zend/tests/gh16665_2.phpt b/Zend/tests/gh16665_2.phpt new file mode 100644 index 0000000000000..3b8ffd4c1e6b0 --- /dev/null +++ b/Zend/tests/gh16665_2.phpt @@ -0,0 +1,8 @@ +--TEST-- +GH-16665 (\callable should not be usable) +--FILE-- + +--EXPECTF-- +Fatal error: Cannot use "callable" as a class alias as it is reserved in %s on line %d diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 73bc661cd40e3..ce8fa88dee3c0 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -214,6 +214,10 @@ static const struct reserved_class_name reserved_class_names[] = { {ZEND_STRL("iterable")}, {ZEND_STRL("object")}, {ZEND_STRL("mixed")}, + /* These are not usable as class names because they're proper tokens, + * but they are here for class aliases. */ + {ZEND_STRL("array")}, + {ZEND_STRL("callable")}, {NULL, 0} };