[phd] master: Fix <function> with <replaceable> not rendering correctly (#235)

From: Date: Thu, 05 Feb 2026 17:08:08 +0000
Subject: [phd] master: Fix <function> with <replaceable> not rendering correctly (#235)
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-23126@lists.php.net to get a copy of this message
Author: Louis-Arnaud (lacatoire) Committer: GitHub (web-flow) Pusher: Girgias Date: 2026-02-05T17:08:04Z Commit: https://github.com/php/phd/commit/5f10df173f923d261fa0ae3aa3b2f5778b327e73 Raw diff: https://github.com/php/phd/commit/5f10df173f923d261fa0ae3aa3b2f5778b327e73.diff Fix <function> with <replaceable> not rendering correctly (#235) When <function> contains <replaceable>, skip link/parentheses processing in format_function_text() and output plain text instead. Uses the role stack pattern already established by format_constant(). Fixes php/phd#171 Changed paths: A tests/package/php/data/function_replaceable_rendering.xml A tests/package/php/function_replaceable_rendering.phpt M phpdotnet/phd/Package/PHP/XHTML.php M phpdotnet/phd/Render.php Diff: diff --git a/phpdotnet/phd/Package/PHP/XHTML.php b/phpdotnet/phd/Package/PHP/XHTML.php index 6d8a4bec..878afb83 100644 --- a/phpdotnet/phd/Package/PHP/XHTML.php +++ b/phpdotnet/phd/Package/PHP/XHTML.php @@ -827,12 +827,24 @@ public function format_classsynopsis_methodsynopsis_methodname_text($value, $tag public function format_function($open, $tag, $attrs, $props) { if ($open) { + if (str_contains($props["innerXml"], '<replaceable')) { + $this->pushRole("function_replaceable"); + } return '<span class="' . $tag . '">'; } + + if ($this->getRole() === "function_replaceable") { + $this->popRole(); + } + return "</span>"; } public function format_function_text($value, $tag, $display_value = null) { + if ($this->getRole() === "function_replaceable") { + return $this->TEXT($value); + } + static $non_functions = array( "echo" => true, "print" => true, "include" => true, "include_once" => true, diff --git a/phpdotnet/phd/Render.php b/phpdotnet/phd/Render.php index 5e4201cd..eeacc68e 100644 --- a/phpdotnet/phd/Render.php +++ b/phpdotnet/phd/Render.php @@ -77,7 +77,7 @@ public function execute(Reader $r) { /* {{{ */ $r->name === "type" || $r->name === "classsynopsis" || $r->name === "qandaset" || - in_array($r->name, ["methodsynopsis", "constructorsynopsis", "destructorsynopsis", "constant"], true) + in_array($r->name, ["methodsynopsis", "constructorsynopsis", "destructorsynopsis", "constant", "function"], true) ) ) { $innerXml = $r->readInnerXml(); diff --git a/tests/package/php/data/function_replaceable_rendering.xml b/tests/package/php/data/function_replaceable_rendering.xml new file mode 100644 index 00000000..75168e33 --- /dev/null +++ b/tests/package/php/data/function_replaceable_rendering.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<chapter xml:id="function_replaceable_rendering" xmlns="http://docbook.org/ns/docbook"> + + <section> + <para>1. Function with replaceable</para> + <para> + <function>xml_set_<replaceable>*</replaceable></function> + </para> + </section> + + <section> + <para>2. Normal function (no replaceable)</para> + <para> + <function>strlen</function> + </para> + </section> + +</chapter> diff --git a/tests/package/php/function_replaceable_rendering.phpt b/tests/package/php/function_replaceable_rendering.phpt new file mode 100644 index 00000000..bd2ae496 --- /dev/null +++ b/tests/package/php/function_replaceable_rendering.phpt @@ -0,0 +1,38 @@ +--TEST-- +Function with replaceable rendering +--FILE-- +<?php +namespace phpdotnet\phd; + +require_once __DIR__ . "/../../setup.php"; + +$xmlFile = __DIR__ . "/data/function_replaceable_rendering.xml"; + +$config->xmlFile = $xmlFile; + +$format = new TestPHPChunkedXHTML($config, $outputHandler); + +$render = new TestRender(new Reader($outputHandler), $config, $format); + +$render->run(); +?> +--EXPECTF-- +Filename: function_replaceable_rendering.html +Content: +<div id="function_replaceable_rendering" class="chapter"> + + <div class="section"> + <p class="para">1. Function with replaceable</p> + <p class="para"> + <span class="function">xml_set_<span class="replaceable">*</span></span> + </p> + </div> + + <div class="section"> + <p class="para">2. Normal function (no replaceable)</p> + <p class="para"> + <span class="function"><strong>strlen()</strong></span> + </p> + </div> + +</div>

« previous php.doc.cvs (#23126) next »