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 printing dropping final on class constants and properties, and
abstract on properties. (Jorg Sowa)

- CLI:
. Fixed bug GH-24697 (PHP_HTTP_PARSER_STRICT build option doesn't work).
Expand Down
36 changes: 36 additions & 0 deletions Zend/tests/assert/expect_final_abstract_modifiers.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
--TEST--
AST printing of final and abstract modifiers on class constants and properties
--INI--
zend.assertions=1
--FILE--
<?php

try {
assert(false && new class {
final public const A = 1;
final protected const int B = 2;
final public $a;
final public static $b;
final public readonly int $c;
abstract public $d { get; }
abstract protected private(set) int $e { set; }
});
} catch (AssertionError $e) {
echo $e->getMessage(), "\n";
}

?>
--EXPECT--
assert(false && new class {
public final const A = 1;
protected final const int B = 2;
public final $a;
public static final $b;
public final readonly int $c;
public abstract $d {
get;
}
protected private(set) abstract int $e {
set;
}
})
9 changes: 9 additions & 0 deletions Zend/zend_ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -2010,6 +2010,12 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
if (ast->attr & ZEND_ACC_STATIC) {
smart_str_appends(str, "static ");
}
if (ast->attr & ZEND_ACC_ABSTRACT) {
smart_str_appends(str, "abstract ");
}
if (ast->attr & ZEND_ACC_FINAL) {
smart_str_appends(str, "final ");
}
if (ast->attr & ZEND_ACC_READONLY) {
smart_str_appends(str, "readonly ");
}
Expand All @@ -2032,6 +2038,9 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
}

zend_ast_export_visibility(str, ast->attr, ZEND_MODIFIER_TARGET_CONSTANT);
if (ast->attr & ZEND_ACC_FINAL) {
smart_str_appends(str, "final ");
}
smart_str_appends(str, "const ");
if (ast->child[2]) {
zend_ast_export_type(str, ast->child[2], indent);
Expand Down
Loading