Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Zend/tests/gh16665_1.phpt
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions Zend/tests/gh16665_2.phpt
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Comment on lines +217 to +218
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about list, while, ..?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment #16683 (comment)

{ZEND_STRL("array")},
{ZEND_STRL("callable")},
{NULL, 0}
};

Expand Down