Skip to content

Commit d980708

Browse files
committed
Merge branch 'PHP-8.5' into PHP-8.6
# Conflicts: # NEWS
2 parents 642899f + 24934c9 commit d980708

3 files changed

Lines changed: 33 additions & 0 deletions

File tree

‎NEWS‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ PHP NEWS
2828
nested isset()/empty(). (Jorg Sowa)
2929
. Fixed anonymous class names being truncated at the NUL byte in error
3030
messages, the error log, and HTML and XML-RPC error output. (Jorg Sowa)
31+
. Fixed AST printing dropping readonly on promoted constructor parameters.
32+
(Jorg Sowa)
3133

3234
- Curl:
3335
. Fixed curl_reset() retaining CURLOPT_PRIVATE after reset. (lacatoire)

‎Zend/zend_ast.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3123,6 +3123,9 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
31233123
if (ast->attr & ZEND_ACC_FINAL) {
31243124
smart_str_appends(str, "final ");
31253125
}
3126+
if (ast->attr & ZEND_ACC_READONLY) {
3127+
smart_str_appends(str, "readonly ");
3128+
}
31263129
if (ast->child[0]) {
31273130
zend_ast_export_type(str, ast->child[0], indent);
31283131
smart_str_appendc(str, ' ');
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
AST can be recreated (readonly promoted constructor parameters)
3+
--EXTENSIONS--
4+
zend_test
5+
--FILE--
6+
<?php
7+
8+
class Foo {
9+
public function __construct(
10+
public readonly int $publicReadonly,
11+
readonly int $implicitlyPublicReadonly,
12+
protected private(set) readonly array $asymmetricReadonly = [],
13+
#[Attr] private readonly ?string $attributedReadonly = null,
14+
public int $notReadonly = 1,
15+
) {}
16+
}
17+
18+
echo zend_test_compile_to_ast( file_get_contents( __FILE__ ) );
19+
20+
?>
21+
--EXPECT--
22+
class Foo {
23+
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) {
24+
}
25+
26+
}
27+
28+
echo zend_test_compile_to_ast(file_get_contents(__FILE__));

0 commit comments

Comments
 (0)