1
0
mirror of https://github.com/php/phd.git synced 2026-03-23 22:52:05 +01:00

Fix rendering of attribute constants (#249)

$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 d7f7004639/phpdotnet/phd/Package/Generic/XHTML.php (L1608)
This commit is contained in:
Máté Kocsis
2026-03-19 22:08:18 +01:00
committed by GitHub
parent 0e43594305
commit e546e7b8d8
3 changed files with 35 additions and 1 deletions

View File

@@ -1427,6 +1427,7 @@ abstract class Package_Generic_XHTML extends Format_Abstract_XHTML {
}
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 @@ abstract class Package_Generic_XHTML extends Format_Abstract_XHTML {
}
return false;
}
$this->cchunk["fieldsynopsis"]["modifier"] = trim($value);
return $this->TEXT($value);
}

View File

@@ -85,4 +85,21 @@ Content:
}</div>
</div>
<div class="section">
<p class="para">3. Constant of a class with attribute</p>
<div class="classsynopsis"><div class="classsynopsisinfo">
<span class="attribute">#[\UnknownAttribute]</span><br>
<span class="modifier">class</span> <strong class="classname">ClassName</strong>
{</div>
<div class="classsynopsisinfo classsynopsisinfo_comment">/* Constants */</div>
<div class="fieldsynopsis">
<span class="modifier">public</span>
<span class="modifier">const</span>
<span class="type">string</span>
<var class="fieldsynopsis_varname">CONSTANT_NAME</var>;</div>
}</div>
</div>
</div>

View File

@@ -35,4 +35,21 @@
</classsynopsis>
</section>
<section>
<para>3. Constant of a class with attribute</para>
<classsynopsis class="class">
<ooclass>
<modifier role="attribute">#[\UnknownAttribute]</modifier>
<classname>ClassName</classname>
</ooclass>
<classsynopsisinfo role="comment">Constants</classsynopsisinfo>
<fieldsynopsis>
<modifier>public</modifier>
<modifier>const</modifier>
<type>string</type>
<varname>CONSTANT_NAME</varname>
</fieldsynopsis>
</classsynopsis>
</section>
</chapter>