Skip to content

Commit cb06eb2

Browse files
committed
Merge branch 'PHP-8.6'
# Conflicts: # NEWS
2 parents a7598d3 + a5d34b4 commit cb06eb2

2 files changed

Lines changed: 73 additions & 0 deletions

File tree

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
--TEST--
2+
Hook parameter list and attributes AST printing
3+
--FILE--
4+
<?php
5+
6+
try {
7+
assert(false && new class {
8+
public int $prop1 {
9+
set(int $value) => $value * 2;
10+
}
11+
public $prop2 {
12+
#[A]
13+
get => $this->prop2;
14+
#[A(1), B]
15+
#[C]
16+
final set($value) {
17+
$this->prop2 = $value;
18+
}
19+
}
20+
public string $prop3 {
21+
set(#[SensitiveParameter] string|int $value) => (string) $value;
22+
}
23+
public $prop4 {
24+
#[A] final &get => $this->prop4;
25+
}
26+
public function __construct(
27+
public int $prop5 {
28+
#[A]
29+
set(int $value) => $value + 1;
30+
},
31+
) {}
32+
});
33+
} catch (Error $e) {
34+
echo $e->getMessage(), "\n";
35+
}
36+
37+
?>
38+
--EXPECT--
39+
assert(false && new class {
40+
public int $prop1 {
41+
set(int $value) => $value * 2;
42+
}
43+
public $prop2 {
44+
#[A]
45+
get => $this->prop2;
46+
#[A(1), B]
47+
#[C]
48+
final set($value) {
49+
$this->prop2 = $value;
50+
}
51+
}
52+
public string $prop3 {
53+
set(#[SensitiveParameter] string|int $value) => (string)$value;
54+
}
55+
public $prop4 {
56+
#[A]
57+
final &get => $this->prop4;
58+
}
59+
public function __construct(public int $prop5 {
60+
#[A]
61+
set(int $value) => $value + 1;
62+
}) {
63+
}
64+
65+
})

‎Zend/zend_ast.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2256,13 +2256,21 @@ static ZEND_COLD void zend_ast_export_hook_list(smart_str *str, const zend_ast_l
22562256

22572257
for (uint32_t i = 0; i < hook_list->children; i++) {
22582258
const zend_ast_decl *hook = (const zend_ast_decl *)hook_list->child[i];
2259+
if (hook->child[4]) {
2260+
zend_ast_export_attributes(str, hook->child[4], indent, 1);
2261+
}
22592262
if (hook->flags & ZEND_ACC_FINAL) {
22602263
smart_str_appends(str, "final ");
22612264
}
22622265
if (hook->flags & ZEND_ACC_RETURN_REFERENCE) {
22632266
smart_str_appendc(str, '&');
22642267
}
22652268
smart_str_append(str, hook->name);
2269+
if (hook->child[0]) {
2270+
smart_str_appendc(str, '(');
2271+
zend_ast_export_ex(str, hook->child[0], 0, indent);
2272+
smart_str_appendc(str, ')');
2273+
}
22662274
zend_ast *body = hook->child[2];
22672275
if (body == NULL) {
22682276
smart_str_appendc(str, ';');

0 commit comments

Comments
 (0)