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