diff --git a/phpdotnet/phd/Package/PHP/XHTML.php b/phpdotnet/phd/Package/PHP/XHTML.php index 9a734eb7..030146b7 100644 --- a/phpdotnet/phd/Package/PHP/XHTML.php +++ b/phpdotnet/phd/Package/PHP/XHTML.php @@ -666,7 +666,7 @@ public function format_type_methodparam_text($type, $tagname) { } public function format_type_text($type, $tagname) { - $t = strtr(strtolower($type), ["_" => "-", "\\" => "-"]); + $t = strtr(ltrim(strtolower($type), "\\"), ["_" => "-", "\\" => "-"]); $fragment = ""; switch($t) { @@ -714,7 +714,7 @@ public function format_type_text($type, $tagname) { return false; } - $classNames = ($type === "?") ? ($tagname . ' null') : ($tagname . ' ' . $type); + $classNames = ($type === "?") ? ($tagname . ' null') : ($tagname . ' ' . ltrim($type, "\\")); if ($href && $this->chunked) { return '' .$type. ''; } @@ -837,7 +837,7 @@ public function format_function_text($value, $tag, $display_value = null) { if (isset($non_functions[$value])) { $filename = "function." . str_replace("_", "-", $value); } else { - $ref = strtolower($value); + $ref = ltrim(strtolower($value), "\\"); $filename = $this->getRefnameLink($ref); } if ($filename !== null) { @@ -880,7 +880,7 @@ public function format_classsynopsis_oo_name_text($value, $tag) { } public function format_classname_text($value, $tag) { - if (($filename = $this->getClassnameLink(strtolower($value))) !== null && $this->cchunk["class_name_ref"] !== strtolower($value)) { + if (($filename = $this->getClassnameLink(ltrim(strtolower($value), "\\"))) !== null && $this->cchunk["class_name_ref"] !== strtolower($value)) { $href = $this->chunked ? $filename.$this->ext : "#$filename"; return '' .$value. ''; } diff --git a/tests/package/php/class_and_method_link_rendering_001.phpt b/tests/package/php/class_and_method_link_rendering_001.phpt new file mode 100644 index 00000000..cb9e04f1 --- /dev/null +++ b/tests/package/php/class_and_method_link_rendering_001.phpt @@ -0,0 +1,79 @@ +--TEST-- +Class and method link rendering 001 +--FILE-- +setXml_file( + __DIR__ . "/data/class_and_method_link_rendering_001.xml" +); + +$indices = [ + [ + "docbook_id" => "class.extension-namespace-existing-class", + "filename" => "extensionname.classpage", + "element" => "phpdoc:classref", + ], + [ + "docbook_id" => "extension-namespace-classname.existingmethodname", + "filename" => "extension-namespace-classname.methodpage", + ], +]; + +$format = new TestPHPChunkedXHTML($config, $outputHandler); + +foreach ($indices as $index) { + $format->SQLiteIndex( + null, // $context, + null, // $index, + $index["docbook_id"] ?? "", // $id, + $index["filename"] ?? "", // $filename, + $index["parent_id"] ?? "", // $parent, + $index["sdesc"] ?? "", // $sdesc, + $index["ldesc"] ?? "", // $ldesc, + $index["element"] ?? "", // $element, + $index["previous"] ?? "", // $previous, + $index["next"] ?? "", // $next, + $index["chunk"] ?? 0, // $chunk + ); +} + +$format->addClassname("class.extension-namespace-existing-class", "extension\\namespace\\existing_class"); +$format->addRefname("extension-namespace-classname.existingmethodname", "extension\\namespace\\classname::existingmethodname"); + +$render = new TestRender(new Reader($outputHandler), $config, $format); + +$render->run(); +?> +--EXPECTF-- +Filename: class_and_method_link_rendering.html +Content: + diff --git a/tests/package/php/data/class_and_method_link_rendering_001.xml b/tests/package/php/data/class_and_method_link_rendering_001.xml new file mode 100644 index 00000000..5f967b18 --- /dev/null +++ b/tests/package/php/data/class_and_method_link_rendering_001.xml @@ -0,0 +1,32 @@ + + + +
+ 1. Class linking + Extension\Namespace\Existing_Class + \Extension\Namespace\Existing_Class +
+ +
+ 2. Method/Function linking + Extension\Namespace\Classname::existingMethodName + \Extension\Namespace\Classname::existingMethodName +
+ +
+ 3. Class linking (non-FQN) in method/function parameter and return type + + Extension\Namespace\Existing_Classmethod_name + Extension\Namespace\Existing_ClassparamName + +
+ +
+ 4. Class linking (FQN) in method/function parameter and return type + + \Extension\Namespace\Existing_Classmethod_name + \Extension\Namespace\Existing_ClassparamName + +
+ +