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 @@ -6,6 +6,8 @@ PHP NEWS
. Fixed AST printing of interface extends list as implements. (Jorg Sowa)
. Fixed AST printing dropping fully qualified and namespace-relative prefixes
of class names in implements, catch, and trait use lists. (Jorg Sowa)
. Fixed AST printing dropping readonly on promoted constructor parameters.
(Jorg Sowa)

- Curl:
. Fixed curl_reset() retaining CURLOPT_PRIVATE after reset. (lacatoire)
Expand Down
3 changes: 3 additions & 0 deletions Zend/zend_ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -2609,6 +2609,9 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
zend_ast_export_attributes(str, ast->child[3], indent, 0);
}
zend_ast_export_visibility(str, ast->attr, ZEND_MODIFIER_TARGET_CPP);
if (ast->attr & ZEND_ACC_READONLY) {
smart_str_appends(str, "readonly ");
}
if (ast->child[0]) {
zend_ast_export_type(str, ast->child[0], indent);
smart_str_appendc(str, ' ');
Expand Down
28 changes: 28 additions & 0 deletions ext/zend_test/tests/compile_to_ast/readonly_promoted.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
--TEST--
AST can be recreated (readonly promoted constructor parameters)
--EXTENSIONS--
zend_test
--FILE--
<?php

class Foo {
public function __construct(
public readonly int $publicReadonly,
readonly int $implicitlyPublicReadonly,
protected private(set) readonly array $asymmetricReadonly = [],
#[Attr] private readonly ?string $attributedReadonly = null,
public int $notReadonly = 1,
) {}
}

echo zend_test_compile_to_ast( file_get_contents( __FILE__ ) );

?>
--EXPECT--
class Foo {
public function __construct(public readonly int $publicReadonly, readonly int $implicitlyPublicReadonly, protected private(set) readonly array $asymmetricReadonly = [], #[Attr] private readonly ?string $attributedReadonly = null, public int $notReadonly = 1) {
}

}

echo zend_test_compile_to_ast(file_get_contents(__FILE__));
Loading