Skip to content

Commit

Permalink
Fix function attribute rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
haszi committed Jun 9, 2024
1 parent aa07a4d commit e434d42
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion phpdotnet/phd/Package/Generic/XHTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ abstract class Package_Generic_XHTML extends Format_Abstract_XHTML {
protected $isSectionChunk = array();
protected $params = array();

private bool $classHasAttributes = false;
protected bool $classHasAttributes = false;

public function __construct() {
parent::__construct();
Expand Down
4 changes: 4 additions & 0 deletions phpdotnet/phd/Package/PHP/XHTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,10 @@ public function format_methodsynopsis_type($open, $tag, $attrs) {
"intersection" => "&",
};
}
if ($this->classHasAttributes) {
$this->classHasAttributes = false;
return "<br>";
}
} else {
if (
isset($attrs[Reader::XMLNS_DOCBOOK]["class"])
Expand Down
17 changes: 17 additions & 0 deletions tests/package/generic/attribute_formatting_002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,21 @@ Content:
}</div>
</div>

<div class="section">
<p class="para">9. Function with unknown attributes</p>
<div class="methodsynopsis dc-description">
<span class="attribute">#[\UnknownAttribute]</span>
<span class="attribute">#[\AnotherUnknownAttribute]</span>
<span class="type">void</span> <span class="methodname">function_name</span>)</div>

</div>

<div class="section">
<p class="para">10. Function with known attributes</p>
<div class="methodsynopsis dc-description"><span class="attribute"><a href="file.knownattribute.is.in.html">#[\KnownAttribute]</a> </span>
<span class="attribute"><a href="file.anotherknownattribute.is.in.html">#[\AnotherKnownAttribute]</a> </span>
<span class="type">void</span> <span class="methodname">function_name</span>)</div>

</div>

</div>
18 changes: 18 additions & 0 deletions tests/package/generic/data/attribute_formatting_002.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,22 @@
</classsynopsis>
</section>

<section>
<para>9. Function with unknown attributes</para>
<methodsynopsis>
<modifier role="attribute">#[\UnknownAttribute]</modifier>
<modifier role="attribute">#[\AnotherUnknownAttribute]</modifier>
<type>void</type><methodname>function_name</methodname>
</methodsynopsis>
</section>

<section>
<para>10. Function with known attributes</para>
<methodsynopsis>
<modifier role="attribute">#[\KnownAttribute]</modifier>
<modifier role="attribute">#[\AnotherKnownAttribute]</modifier>
<type>void</type><methodname>function_name</methodname>
</methodsynopsis>
</section>

</chapter>

0 comments on commit e434d42

Please sign in to comment.