From 870c6bed6506facacd136ea3723bd11bcb76bc8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Wed, 11 Mar 2026 10:37:41 +0100 Subject: [PATCH 1/2] Fix rendering of attribute constants $this->cchunk["fieldsynopsis"]["modifier"] was not set for atrributes due to the early return, but this value is needed in order to be able to decide if the fieldsynopsis refers to a constant or a property at https://github.com/php/phd/blob/d7f700463918a466705e92b4bfd4df0afa39d944/phpdotnet/phd/Package/Generic/XHTML.php#L1608 --- phpdotnet/phd/Package/Generic/XHTML.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpdotnet/phd/Package/Generic/XHTML.php b/phpdotnet/phd/Package/Generic/XHTML.php index 0b5fb7fd..e5cdaed5 100644 --- a/phpdotnet/phd/Package/Generic/XHTML.php +++ b/phpdotnet/phd/Package/Generic/XHTML.php @@ -1427,6 +1427,7 @@ public function format_fieldsynopsis($open, $name, $attrs) { } public function format_fieldsynopsis_modifier_text($value, $tag) { + $this->cchunk["fieldsynopsis"]["modifier"] = trim($value); if ($this->getRole() === "attribute") { $attribute = trim(strtolower($value), "#[]\\"); $href = Format::getFilename("class.$attribute"); @@ -1435,7 +1436,6 @@ public function format_fieldsynopsis_modifier_text($value, $tag) { } return false; } - $this->cchunk["fieldsynopsis"]["modifier"] = trim($value); return $this->TEXT($value); } From b79ab5fd4b66bf1d9b5efbf8f2f8b00b4272fd39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Mon, 16 Mar 2026 16:19:09 +0100 Subject: [PATCH 2/2] Add test --- .../generic/attribute_formatting_003.phpt | 17 +++++++++++++++++ .../generic/data/attribute_formatting_003.xml | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/tests/package/generic/attribute_formatting_003.phpt b/tests/package/generic/attribute_formatting_003.phpt index ded7e667..00ce7e77 100644 --- a/tests/package/generic/attribute_formatting_003.phpt +++ b/tests/package/generic/attribute_formatting_003.phpt @@ -85,4 +85,21 @@ Content: } +
+

3. Constant of a class with attribute

+
+ + #[\UnknownAttribute]
+ class ClassName + {
+
/* Constants */
+
+ public + const + string + CONSTANT_NAME;
+ + }
+
+ diff --git a/tests/package/generic/data/attribute_formatting_003.xml b/tests/package/generic/data/attribute_formatting_003.xml index 3905c5c8..f3de65c9 100644 --- a/tests/package/generic/data/attribute_formatting_003.xml +++ b/tests/package/generic/data/attribute_formatting_003.xml @@ -35,4 +35,21 @@ +
+ 3. Constant of a class with attribute + + + #[\UnknownAttribute] + ClassName + + Constants + + public + const + string + CONSTANT_NAME + + +
+