From ddb8abfd0938adbb880190cfe2d012fb29c0933e Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sun, 13 Sep 2020 12:03:52 +0200 Subject: [PATCH 1/2] =?UTF-8?q?Support=20variadic=20parameters=20=E2=80=93?= =?UTF-8?q?=20take=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit So far, PhD does not support variadic parameters. Instead the manual follows the convention to use `...` as parameter name, which is then rendered as `$...` in the docs. However, as of PHP 5.6.0 variadic parameters are supported using the syntax `...$args`; therefore, we are going to support this notation for PhD. While DocBook supports a `` element, this cannot be used in combination with named parameters. Therefore, we use the `rep` attribute of the `` element to designate variadic parameters. --- phpdotnet/phd/Package/Generic/XHTML.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/phpdotnet/phd/Package/Generic/XHTML.php b/phpdotnet/phd/Package/Generic/XHTML.php index 798175bf..d2486990 100644 --- a/phpdotnet/phd/Package/Generic/XHTML.php +++ b/phpdotnet/phd/Package/Generic/XHTML.php @@ -976,7 +976,7 @@ public function format_fieldsynopsis_modifier_text($value, $tag) { public function format_methodsynopsis($open, $name, $attrs) { if ($open) { - $this->params = array("count" => 0, "opt" => 0, "content" => ""); + $this->params = array("count" => 0, "opt" => 0, "content" => "", "repeatable" => ''); $id = (isset($attrs[Reader::XMLNS_XML]["id"]) ? ' id="'.$attrs[Reader::XMLNS_XML]["id"].'"' : ''); return '
'; } @@ -998,9 +998,9 @@ public function format_methodparam_parameter($open, $name, $attrs, $props) } if ($open) { if (isset($attrs[Reader::XMLNS_DOCBOOK]["role"])) { - return ' &$'; + return ' &' . $this->params["ellipsis"] . '$'; } - return ' $'; + return ' ' . $this->params["ellipsis"] . '$'; } return ""; } @@ -1051,6 +1051,11 @@ public function format_methodparam($open, $name, $attrs) { } $content .= ' '; ++$this->params["count"]; + if (isset($attrs[Reader::XMLNS_DOCBOOK]["rep"]) && $attrs[Reader::XMLNS_DOCBOOK]["rep"] == "repeat") { + $this->params["ellipsis"] = '...'; + } else { + $this->params["ellipsis"] = ''; + } return $content; } return ""; From 853a2b10a964cb985e24da7ef408e68358d2bd18 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Thu, 29 Oct 2020 23:53:06 +0100 Subject: [PATCH 2/2] Match key names --- 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 d2486990..8b551f49 100644 --- a/phpdotnet/phd/Package/Generic/XHTML.php +++ b/phpdotnet/phd/Package/Generic/XHTML.php @@ -976,7 +976,7 @@ public function format_fieldsynopsis_modifier_text($value, $tag) { public function format_methodsynopsis($open, $name, $attrs) { if ($open) { - $this->params = array("count" => 0, "opt" => 0, "content" => "", "repeatable" => ''); + $this->params = array("count" => 0, "opt" => 0, "content" => "", "ellipsis" => ''); $id = (isset($attrs[Reader::XMLNS_XML]["id"]) ? ' id="'.$attrs[Reader::XMLNS_XML]["id"].'"' : ''); return '
'; }