Skip to content
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
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ PHP NEWS
(Marti2203).
. Fixed bug GH-24989 (Use-after-free in GC when an exception is thrown).
(David Carlier)
. Fixed AST export of readonly anonymous classes dropping the readonly
modifier. (Jorg Sowa)

- CLI:
. Fixed bug GH-24697 (PHP_HTTP_PARSER_STRICT build option doesn't work).
Expand Down
22 changes: 22 additions & 0 deletions Zend/tests/assert/expect_readonly_anon_class.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--TEST--
AST export of readonly anonymous class
--INI--
zend.assertions=1
--FILE--
<?php
try {
assert(false && new readonly class {});
} catch (AssertionError $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
try {
assert(false && new #[A] readonly class(1) {});
} catch (AssertionError $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECT--
AssertionError: assert(false && new readonly class {
})
AssertionError: assert(false && new #[A] readonly class(1) {
})
3 changes: 3 additions & 0 deletions Zend/zend_ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -2311,6 +2311,9 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
if (decl->child[3]) {
zend_ast_export_attributes(str, decl->child[3], indent, 0);
}
if (decl->flags & ZEND_ACC_READONLY_CLASS) {
smart_str_appends(str, "readonly ");
}
smart_str_appends(str, "class");
if (!zend_ast_is_list(ast->child[1])
|| zend_ast_get_list(ast->child[1])->children) {
Expand Down
Loading