Skip to content
Merged
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
42 changes: 36 additions & 6 deletions phpdotnet/phd/Package/Generic/XHTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,11 @@ abstract class Package_Generic_XHTML extends Format_Abstract_XHTML {
'constant' => 'format_suppressed_text',
),
/** Those are used to retrieve the class/interface name to be able to remove it from method names */
'package' => [
/* DEFAULT */ false,
'packagesynopsis' => 'format_packagesynopsis_package_text'
],
/** Those are used to retrieve the class/interface name to be able to remove it from method names */
'classname' => [
/* DEFAULT */ false,
'ooclass' => [
Expand Down Expand Up @@ -538,7 +543,10 @@ abstract class Package_Generic_XHTML extends Format_Abstract_XHTML {
protected $cchunk = array();
/* Default Chunk variables */
private $dchunk = array(
"packagesynopsis" => false,
"packagesynopsis" => [
"open" => false,
"namespace" => '',
],
"classsynopsis" => [
"close" => false,
"classname" => false,
Expand Down Expand Up @@ -1257,7 +1265,7 @@ public function format_classsynopsis($open, $name, $attrs, $props) {
/** Legacy presentation does not use the class attribute */
$this->cchunk["classsynopsis"]['legacy'] = !isset($attrs[Reader::XMLNS_DOCBOOK]["class"]);

$inPackageSynopsis = $this->cchunk["packagesynopsis"] ?? false;
$inPackageSynopsis = $this->cchunk["packagesynopsis"]["open"] ?? false;

if ($this->cchunk["classsynopsis"]['legacy']) {
if ($open) {
Expand Down Expand Up @@ -1324,18 +1332,22 @@ public function format_classsynopsis_methodsynopsis_methodname_text($value, $tag
}

list($class, $method) = explode($explode, $value);
if ($class !== $this->cchunk["classsynopsis"]["classname"]) {
$thisFqcn = $this->getFqcn();

if ($class !== $thisFqcn) {
return $value;
}

return $method;
}

public function format_packagesynopsis($open, $name, $attrs, $props) {
$this->cchunk["packagesynopsis"] = $this->dchunk["packagesynopsis"];
if ($open) {
$this->cchunk["packagesynopsis"] = true;
$this->cchunk["packagesynopsis"]["open"] = true;
return '<div class="classsynopsis"><div class="classsynopsisinfo">';
}
$this->cchunk["packagesynopsis"] = false;
$this->cchunk["packagesynopsis"]["open"] = false;
return '</div>';
}

Expand All @@ -1346,8 +1358,16 @@ public function format_packagesynopsis_package($open, $name, $attrs, $props) {
return '</strong>;</div>';
}

public function format_packagesynopsis_package_text($value, $tag) {
if (!$this->cchunk["packagesynopsis"]["namespace"]) {
$this->cchunk["packagesynopsis"]["namespace"] = $value;
}

return $this->TEXT($value);
}

public function format_enumsynopsis($open, $name, $attrs, $props) {
$inPackageSynopsis = $this->cchunk["packagesynopsis"] ?? false;
$inPackageSynopsis = $this->cchunk["packagesynopsis"]["open"] ?? false;
if ($open) {
if ($inPackageSynopsis) {
return '<div class="classsynopsisinfo">';
Expand Down Expand Up @@ -2683,4 +2703,14 @@ public function onNewPage(): void
{
$this->perPageExampleCounter = 0;
}

protected function getFqcn() {
$fqcn = "";

if ($this->cchunk["packagesynopsis"]["namespace"]) {
$fqcn = $this->cchunk["packagesynopsis"]["namespace"] . "\\";
}

return $fqcn . $this->cchunk["classsynopsis"]["classname"];
}
}
4 changes: 2 additions & 2 deletions phpdotnet/phd/Package/PHP/XHTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ public function format_acronym_text($value, $tag) {
public function format_classsynopsis_fieldsynopsis_varname_text($value, $tag) {
if ($this->cchunk["classsynopsis"]["classname"]) {
if (strpos($value, "::") === false && strpos($value, "->") === false) {
$value = $this->cchunk["classsynopsis"]["classname"] . "->" . $value;
$value = $this->getFqcn() . "->" . $value;
}
}

Expand All @@ -817,7 +817,7 @@ public function format_classsynopsis_fieldsynopsis_varname_text($value, $tag) {
public function format_classsynopsis_methodsynopsis_methodname_text($value, $tag) {
if ($this->cchunk["classsynopsis"]["classname"]) {
if (strpos($value, "::") === false && strpos($value, "->") === false) {
$value = $this->cchunk["classsynopsis"]["classname"] . "::" . $value;
$value = $this->getFqcn() . "::" . $value;
}
}

Expand Down
11 changes: 11 additions & 0 deletions tests/package/php/data/packagesynopsis_rendering.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@
<modifier>implements</modifier>
<interfacename>Stringable</interfacename>
</oointerface>

<fieldsynopsis>
<modifier>public</modifier>
<type>int</type>
<varname linkend="bcmath-number.props.scale">scale</varname>
</fieldsynopsis>

<methodsynopsis xmlns="http://docbook.org/ns/docbook" role="BcMath\\Number">
<modifier>public</modifier> <type>BcMath\Number</type><methodname>BcMath\Number::floor</methodname>
<void/>
</methodsynopsis>
</classsynopsis>
</packagesynopsis>
</section>
Expand Down
10 changes: 10 additions & 0 deletions tests/package/php/packagesynopsis_rendering_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ Content:

<span class="modifier">implements</span>
<strong class="interfacename">Stringable</strong> {</div>

<div class="fieldsynopsis">
<span class="modifier">public</span>
<span class="type"><a href="language.types.integer.html" class="type int">int</a></span>
<var class="varname"><a href=".html#bcmath-number.props.scale">$<var class="varname">scale</var></a></var>;</div>


<div class="methodsynopsis dc-description">
<span class="modifier">public</span> <span class="methodname"><strong>floor</strong></span>(): <span class="type">BcMath\Number</span></div>

}
</div>
</div>
Expand Down