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 @@ -34,6 +34,8 @@ PHP NEWS
. Fixed bug GH-25311 (Assertion ret == SUCCESS in array_map()/array_filter()
after delayed out-of-memory). (ndossche)
. Fixed AST export of by-reference property hooks. (Jorg Sowa)
. Fixed AST export of property hook parameter lists and attributes.
(Jorg Sowa)

- Curl:
. Fixed curl_reset() retaining CURLOPT_PRIVATE after reset. (lacatoire)
Expand Down
65 changes: 65 additions & 0 deletions Zend/tests/property_hooks/ast_printing_params_attributes.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
--TEST--
Hook parameter list and attributes AST printing
--FILE--
<?php

try {
assert(false && new class {
public int $prop1 {
set(int $value) => $value * 2;
}
public $prop2 {
#[A]
get => $this->prop2;
#[A(1), B]
#[C]
final set($value) {
$this->prop2 = $value;
}
}
public string $prop3 {
set(#[SensitiveParameter] string|int $value) => (string) $value;
}
public $prop4 {
#[A] final &get => $this->prop4;
}
public function __construct(
public int $prop5 {
#[A]
set(int $value) => $value + 1;
},
) {}
});
} catch (Error $e) {
echo $e->getMessage(), "\n";
}

?>
--EXPECT--
assert(false && new class {
public int $prop1 {
set(int $value) => $value * 2;
}
public $prop2 {
#[A]
get => $this->prop2;
#[A(1), B]
#[C]
final set($value) {
$this->prop2 = $value;
}
}
public string $prop3 {
set(#[SensitiveParameter] string|int $value) => (string)$value;
}
public $prop4 {
#[A]
final &get => $this->prop4;
}
public function __construct(public int $prop5 {
#[A]
set(int $value) => $value + 1;
}) {
}

})
8 changes: 8 additions & 0 deletions Zend/zend_ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -2255,13 +2255,21 @@ static ZEND_COLD void zend_ast_export_hook_list(smart_str *str, const zend_ast_l

for (uint32_t i = 0; i < hook_list->children; i++) {
const zend_ast_decl *hook = (const zend_ast_decl *)hook_list->child[i];
if (hook->child[4]) {
zend_ast_export_attributes(str, hook->child[4], indent, 1);
}
if (hook->flags & ZEND_ACC_FINAL) {
smart_str_appends(str, "final ");
}
if (hook->flags & ZEND_ACC_RETURN_REFERENCE) {
smart_str_appendc(str, '&');
}
smart_str_append(str, hook->name);
if (hook->child[0]) {
smart_str_appendc(str, '(');
zend_ast_export_ex(str, hook->child[0], 0, indent);
smart_str_appendc(str, ')');
}
zend_ast *body = hook->child[2];
if (body == NULL) {
smart_str_appendc(str, ';');
Expand Down
Loading