1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Fix GH-16665: \array and \callable should not be usable

This list was initially introduced in 53a40386, but never included array or
callable. I suppose this is because int & friends are not actual tokens,
while array and callable are. This means it was never possible to do class
array, which is probably the reason this was overlooked.

Closes GH-16683.
This commit is contained in:
Niels Dossche
2024-11-02 18:52:10 +01:00
parent bc4fa01de7
commit 96d1cd00b7
5 changed files with 28 additions and 0 deletions

4
NEWS
View File

@@ -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)

View File

@@ -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.

View File

@@ -0,0 +1,8 @@
--TEST--
GH-16665 (\array should not be usable)
--FILE--
<?php
class_alias('stdClass', 'array');
?>
--EXPECTF--
Fatal error: Cannot use "array" as a class alias as it is reserved in %s on line %d

View File

@@ -0,0 +1,8 @@
--TEST--
GH-16665 (\callable should not be usable)
--FILE--
<?php
class_alias('stdClass', 'callable');
?>
--EXPECTF--
Fatal error: Cannot use "callable" as a class alias as it is reserved in %s on line %d

View File

@@ -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}
};