From 816a1690a2dd4b5d81853a335257b03e797f7345 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Tue, 13 Dec 2022 20:24:24 +0100 Subject: [PATCH 1/4] Replace another root XML element format to the "canonical" one --- build/gen_stub.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/build/gen_stub.php b/build/gen_stub.php index 8cf319ceaea39..5f6bffd8b09f3 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -4261,16 +4261,18 @@ function replaceClassSynopses(string $targetDirectory, array $classMap, iterable $replacedXml = preg_replace( [ "/REPLACED-ENTITY-([A-Za-z0-9._{}%-]+?;)/", - "//i", - "//i", - "//i", - "//i", + '//i', + '//i', + '//i', + '//i', + '//i', ], [ "&$1", "", "", "", + "", "", ], $replacedXml @@ -4494,8 +4496,8 @@ function replaceMethodSynopses(string $targetDirectory, array $funcMap, array $a $replacedXml = preg_replace( [ "/REPLACED-ENTITY-([A-Za-z0-9._{}%-]+?;)/", - "//i", - "//i", + '//i', + '//i', ], [ "&$1", From 4e58050f28b5494bae9b8bb7077ffce9db6adca7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Tue, 13 Dec 2022 20:27:09 +0100 Subject: [PATCH 2/4] Remove the superfluous closing parentheses from class synopsis page includes --- build/gen_stub.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/gen_stub.php b/build/gen_stub.php index 5f6bffd8b09f3..1be94cd00434c 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -2807,7 +2807,7 @@ public function getClassSynopsisElement(DOMDocument $doc, array $classMap, itera $parentReference = self::getClassSynopsisReference($parent); $includeElement = $this->createIncludeElement( $doc, - "xmlns(db=http://docbook.org/ns/docbook) xpointer(id('$parentReference')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])" + "xmlns(db=http://docbook.org/ns/docbook) xpointer(id('$parentReference')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[@role='$escapedParentName'])" ); $classSynopsis->appendChild($includeElement); } From 3de4d80044387ea995cd6916be5762bd2997eaad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Tue, 13 Dec 2022 20:41:16 +0100 Subject: [PATCH 3/4] Always include the constructor on the class manual pages --- build/gen_stub.php | 56 +++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/build/gen_stub.php b/build/gen_stub.php index 1be94cd00434c..945f9aa548742 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -2760,40 +2760,36 @@ public function getClassSynopsisElement(DOMDocument $doc, array $classMap, itera "&InheritedProperties;" ); - if (!empty($this->funcInfos)) { - $classSynopsis->appendChild(new DOMText("\n\n ")); - $classSynopsisInfo = $doc->createElement("classsynopsisinfo", "&Methods;"); - $classSynopsisInfo->setAttribute("role", "comment"); - $classSynopsis->appendChild($classSynopsisInfo); + $classSynopsis->appendChild(new DOMText("\n\n ")); + $classSynopsisInfo = $doc->createElement("classsynopsisinfo", "&Methods;"); + $classSynopsisInfo->setAttribute("role", "comment"); + $classSynopsis->appendChild($classSynopsisInfo); - $classReference = self::getClassSynopsisReference($this->name); + $classReference = self::getClassSynopsisReference($this->name); - if ($this->hasConstructor()) { - $classSynopsis->appendChild(new DOMText("\n ")); - $includeElement = $this->createIncludeElement( - $doc, - "xmlns(db=http://docbook.org/ns/docbook) xpointer(id('$classReference')/db:refentry/db:refsect1[@role='description']/descendant::db:constructorsynopsis[not(@role='procedural')])" - ); - $classSynopsis->appendChild($includeElement); - } + $classSynopsis->appendChild(new DOMText("\n ")); + $includeElement = $this->createIncludeElement( + $doc, + "xmlns(db=http://docbook.org/ns/docbook) xpointer(id('$classReference')/db:refentry/db:refsect1[@role='description']/descendant::db:constructorsynopsis[not(@role='procedural')])" + ); + $classSynopsis->appendChild($includeElement); - if ($this->hasMethods()) { - $classSynopsis->appendChild(new DOMText("\n ")); - $includeElement = $this->createIncludeElement( - $doc, - "xmlns(db=http://docbook.org/ns/docbook) xpointer(id('$classReference')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])" - ); - $classSynopsis->appendChild($includeElement); - } + if ($this->hasMethods()) { + $classSynopsis->appendChild(new DOMText("\n ")); + $includeElement = $this->createIncludeElement( + $doc, + "xmlns(db=http://docbook.org/ns/docbook) xpointer(id('$classReference')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])" + ); + $classSynopsis->appendChild($includeElement); + } - if ($this->hasDestructor()) { - $classSynopsis->appendChild(new DOMText("\n ")); - $includeElement = $this->createIncludeElement( - $doc, - "xmlns(db=http://docbook.org/ns/docbook) xpointer(id('$classReference')/db:refentry/db:refsect1[@role='description']/descendant::db:destructorsynopsis[not(@role='procedural')])" - ); - $classSynopsis->appendChild($includeElement); - } + if ($this->hasDestructor()) { + $classSynopsis->appendChild(new DOMText("\n ")); + $includeElement = $this->createIncludeElement( + $doc, + "xmlns(db=http://docbook.org/ns/docbook) xpointer(id('$classReference')/db:refentry/db:refsect1[@role='description']/descendant::db:destructorsynopsis[not(@role='procedural')])" + ); + $classSynopsis->appendChild($includeElement); } if (!empty($parentsWithInheritedMethods)) { From 451ad91a538096bfd911efb5b6872f2408fe6291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Fri, 16 Dec 2022 12:07:23 +0100 Subject: [PATCH 4/4] Backport methodsynopsis role attributes changes from master Commits https://github.com/php/php-src/commit/93605f286d11876da44d2ecd41c13d7e3f0aae66 and https://github.com/php/php-src/commit/d6651426f405342f74cdfe930448912ef68e23c4 --- build/gen_stub.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/build/gen_stub.php b/build/gen_stub.php index 945f9aa548742..6af9e06d16acb 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -1487,14 +1487,10 @@ public function getMethodSynopsisElement(array $funcMap, array $aliasMap, DOMDoc $methodSynopsis = $doc->createElement($synopsisType); - $aliasedFunc = $this->aliasType === "alias" && isset($funcMap[$this->alias->__toString()]) ? $funcMap[$this->alias->__toString()] : null; - $aliasFunc = $aliasMap[$this->name->__toString()] ?? null; - - if (($this->aliasType === "alias" && $aliasedFunc !== null && $aliasedFunc->isMethod() !== $this->isMethod()) || - ($aliasFunc !== null && $aliasFunc->isMethod() !== $this->isMethod()) - ) { + if ($this->isMethod()) { + assert($this->name instanceof MethodName); $role = $doc->createAttribute("role"); - $role->value = $this->isMethod() ? "oop" : "procedural"; + $role->value = addslashes($this->name->className->__toString()); $methodSynopsis->appendChild($role); } @@ -2766,11 +2762,12 @@ public function getClassSynopsisElement(DOMDocument $doc, array $classMap, itera $classSynopsis->appendChild($classSynopsisInfo); $classReference = self::getClassSynopsisReference($this->name); + $escapedName = addslashes($this->name->__toString()); $classSynopsis->appendChild(new DOMText("\n ")); $includeElement = $this->createIncludeElement( $doc, - "xmlns(db=http://docbook.org/ns/docbook) xpointer(id('$classReference')/db:refentry/db:refsect1[@role='description']/descendant::db:constructorsynopsis[not(@role='procedural')])" + "xmlns(db=http://docbook.org/ns/docbook) xpointer(id('$classReference')/db:refentry/db:refsect1[@role='description']/descendant::db:constructorsynopsis[@role='$escapedName'])" ); $classSynopsis->appendChild($includeElement); @@ -2778,7 +2775,7 @@ public function getClassSynopsisElement(DOMDocument $doc, array $classMap, itera $classSynopsis->appendChild(new DOMText("\n ")); $includeElement = $this->createIncludeElement( $doc, - "xmlns(db=http://docbook.org/ns/docbook) xpointer(id('$classReference')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])" + "xmlns(db=http://docbook.org/ns/docbook) xpointer(id('$classReference')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[@role='$escapedName'])" ); $classSynopsis->appendChild($includeElement); } @@ -2787,7 +2784,7 @@ public function getClassSynopsisElement(DOMDocument $doc, array $classMap, itera $classSynopsis->appendChild(new DOMText("\n ")); $includeElement = $this->createIncludeElement( $doc, - "xmlns(db=http://docbook.org/ns/docbook) xpointer(id('$classReference')/db:refentry/db:refsect1[@role='description']/descendant::db:destructorsynopsis[not(@role='procedural')])" + "xmlns(db=http://docbook.org/ns/docbook) xpointer(id('$classReference')/db:refentry/db:refsect1[@role='description']/descendant::db:destructorsynopsis[@role='$escapedName'])" ); $classSynopsis->appendChild($includeElement); } @@ -2801,6 +2798,7 @@ public function getClassSynopsisElement(DOMDocument $doc, array $classMap, itera foreach ($parentsWithInheritedMethods as $parent) { $classSynopsis->appendChild(new DOMText("\n ")); $parentReference = self::getClassSynopsisReference($parent); + $escapedParentName = addslashes($parent->__toString()); $includeElement = $this->createIncludeElement( $doc, "xmlns(db=http://docbook.org/ns/docbook) xpointer(id('$parentReference')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[@role='$escapedParentName'])"