From 85332bf7123eabef3a6414055f6d78e1ed9a54ea Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Fri, 13 Nov 2020 15:36:00 +0000 Subject: [PATCH 1/6] Link types to their own type page/section --- phpdotnet/phd/Package/PHP/XHTML.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/phpdotnet/phd/Package/PHP/XHTML.php b/phpdotnet/phd/Package/PHP/XHTML.php index 50f52131..c75e242d 100644 --- a/phpdotnet/phd/Package/PHP/XHTML.php +++ b/phpdotnet/phd/Package/PHP/XHTML.php @@ -541,6 +541,10 @@ public function format_type_text($type, $tagname) { case "double": $href = "language.types.float"; break; + // old name for callable + case "callback": + $href = "language.types.callable"; + break; case "boolean": case "integer": case "float": @@ -557,6 +561,8 @@ public function format_type_text($type, $tagname) { $href = "language.types.$t"; break; case "mixed": + case "void": + case "static": $href = "language.types.declarations"; $fragment = "language.types.declarations.$t"; break; From 6e0bb4df34c51b009421a89035a111ff2c79300a Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Fri, 13 Nov 2020 15:42:13 +0000 Subject: [PATCH 2/6] Always format type elements so that they link to their type page --- phpdotnet/phd/Package/PHP/XHTML.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/phpdotnet/phd/Package/PHP/XHTML.php b/phpdotnet/phd/Package/PHP/XHTML.php index c75e242d..94fe8556 100644 --- a/phpdotnet/phd/Package/PHP/XHTML.php +++ b/phpdotnet/phd/Package/PHP/XHTML.php @@ -107,13 +107,13 @@ abstract class Package_PHP_XHTML extends Package_Generic_XHTML { ), 'refname' => 'format_refname_text', 'type' => array( - /* DEFAULT */ 'format_type_if_object_or_pseudo_text', + /* DEFAULT */ 'format_type_text', 'classsynopsisinfo' => false, - 'fieldsynopsis' => 'format_type_if_object_or_pseudo_text', - 'methodparam' => 'format_type_if_object_or_pseudo_text', + 'fieldsynopsis' => 'format_type_text', + 'methodparam' => 'format_type_text', 'methodsynopsis' => 'format_type_methodsynopsis_text', 'type' => array( - /* DEFAULT */ 'format_type_if_object_or_pseudo_text', + /* DEFAULT */ 'format_type_text', 'methodsynopsis' => 'format_type_methodsynopsis_text', ), ), @@ -486,7 +486,7 @@ public function format_methodsynopsis($open, $name, $attrs, $props) { } foreach ($this->cchunk["methodsynopsis"]["returntypes"] as $return_type) { - $formatted_type = self::format_type_if_object_or_pseudo_text($return_type, "type"); + $formatted_type = self::format_type_text($return_type, "type"); if ($formatted_type === false) { $formatted_type = $return_type; } From 4018eeed7722d87ba9d7ac7362fa8278552f02c1 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Tue, 27 Jul 2021 00:38:26 +0200 Subject: [PATCH 3/6] Drop types which should not be handled there --- phpdotnet/phd/Package/PHP/XHTML.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/phpdotnet/phd/Package/PHP/XHTML.php b/phpdotnet/phd/Package/PHP/XHTML.php index 94fe8556..2f1884d7 100644 --- a/phpdotnet/phd/Package/PHP/XHTML.php +++ b/phpdotnet/phd/Package/PHP/XHTML.php @@ -541,10 +541,6 @@ public function format_type_text($type, $tagname) { case "double": $href = "language.types.float"; break; - // old name for callable - case "callback": - $href = "language.types.callable"; - break; case "boolean": case "integer": case "float": @@ -561,8 +557,6 @@ public function format_type_text($type, $tagname) { $href = "language.types.$t"; break; case "mixed": - case "void": - case "static": $href = "language.types.declarations"; $fragment = "language.types.declarations.$t"; break; From de0a65705dce65368e3592faaac81f72f3e143b7 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Tue, 27 Jul 2021 00:43:08 +0200 Subject: [PATCH 4/6] Remove format_type_if_object_or_pseudo_text() function --- phpdotnet/phd/Package/PHP/XHTML.php | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/phpdotnet/phd/Package/PHP/XHTML.php b/phpdotnet/phd/Package/PHP/XHTML.php index 2f1884d7..d0e50bc9 100644 --- a/phpdotnet/phd/Package/PHP/XHTML.php +++ b/phpdotnet/phd/Package/PHP/XHTML.php @@ -515,18 +515,6 @@ public function format_type_methodsynopsis_text($type, $tagname) { return ""; } - public function format_type_if_object_or_pseudo_text($type, $tagname) { - if (strtolower($type) === "null" && $this->simple_nullable) { - return ""; - } - - if (in_array(strtolower($type), array("bool", "int", "double", "boolean", "integer", "float", "string", "array", "object", "resource", "null"))) { - return false; - } - - return self::format_type_text($type, $tagname); - } - public function format_type_text($type, $tagname) { $t = strtr(strtolower($type), ["_" => "-", "\\" => "-"]); $href = $fragment = ""; From 49b2b7d634888137b8c1ca6a4f67cad5b1b438c7 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Tue, 27 Jul 2021 01:38:07 +0200 Subject: [PATCH 5/6] Add link to null for simple nullable types --- phpdotnet/phd/Package/PHP/XHTML.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/phpdotnet/phd/Package/PHP/XHTML.php b/phpdotnet/phd/Package/PHP/XHTML.php index d0e50bc9..81e04819 100644 --- a/phpdotnet/phd/Package/PHP/XHTML.php +++ b/phpdotnet/phd/Package/PHP/XHTML.php @@ -482,7 +482,12 @@ public function format_methodsynopsis($open, $name, $attrs, $props) { ) { $this->simple_nullable = true; $this->type_separator = ""; - $types[] = '?'; + + if ($this->chunked) { + $types[] = '?'; + } else { + $types[] = '?'; + } } foreach ($this->cchunk["methodsynopsis"]["returntypes"] as $return_type) { From 263f953b0cfce6d2a6e631b31ac765c75f4aeeb8 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Thu, 29 Jul 2021 01:28:14 +0200 Subject: [PATCH 6/6] Maybe fix generation for nullable types --- phpdotnet/phd/Package/PHP/XHTML.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/phpdotnet/phd/Package/PHP/XHTML.php b/phpdotnet/phd/Package/PHP/XHTML.php index 81e04819..5eb66318 100644 --- a/phpdotnet/phd/Package/PHP/XHTML.php +++ b/phpdotnet/phd/Package/PHP/XHTML.php @@ -331,7 +331,12 @@ public function format_type($open, $tag, $attrs, $props) { ) { $this->simple_nullable = true; $this->type_separator = ""; - $retval .= '?'; + + if ($this->chunked) { + $retval .= '?'; + } else { + $retval .= '?'; + } } else { $this->type_separator = $isUnionType ? "|" : "&"; }