Skip to content

Commit 0462719

Browse files
committed
Fix class synopsis generation
Closes GH-7891
1 parent 46bec6d commit 0462719

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

build/gen_stub.php

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,9 +1540,9 @@ public function getFieldSynopsisElement(DOMDocument $doc): DOMElement
15401540
$fieldsynopsisElement->appendChild(new DOMText("\n "));
15411541
$fieldsynopsisElement->appendChild($this->getFieldSynopsisType()->getTypeForDoc($doc));
15421542

1543-
$className = str_replace("\\", "-", $this->name->class->toLowerString());
1543+
$className = str_replace(["\\", "_"], ["-", "-"], $this->name->class->toLowerString());
15441544
$varnameElement = $doc->createElement("varname", $this->name->property);
1545-
$varnameElement->setAttribute("linkend", "$className.props." . strtolower($this->name->property));
1545+
$varnameElement->setAttribute("linkend", "$className.props." . strtolower(str_replace("_", "-", $this->name->property)));
15461546
$fieldsynopsisElement->appendChild(new DOMText("\n "));
15471547
$fieldsynopsisElement->appendChild($varnameElement);
15481548

@@ -1558,14 +1558,14 @@ public function getFieldSynopsisElement(DOMDocument $doc): DOMElement
15581558
}
15591559

15601560
private function getFieldSynopsisType(): Type {
1561-
if ($this->type) {
1562-
return $this->type;
1563-
}
1564-
15651561
if ($this->phpDocType) {
15661562
return $this->phpDocType;
15671563
}
15681564

1565+
if ($this->type) {
1566+
return $this->type;
1567+
}
1568+
15691569
throw new Exception("A property must have a type");
15701570
}
15711571

@@ -2005,11 +2005,11 @@ private static function createOoElement(
20052005
}
20062006

20072007
public static function getClassSynopsisFilename(Name $name): string {
2008-
return strtolower(implode('-', $name->parts));
2008+
return strtolower(str_replace("_", "-", implode('-', $name->parts)));
20092009
}
20102010

20112011
public static function getClassSynopsisReference(Name $name): string {
2012-
return "class." . strtolower(implode('-', $name->parts));
2012+
return "class." . self::getClassSynopsisFilename($name);
20132013
}
20142014

20152015
/**
@@ -2019,10 +2019,6 @@ public static function getClassSynopsisReference(Name $name): string {
20192019
*/
20202020
private function collectInheritedMembers(array &$parentsWithInheritedProperties, array &$parentsWithInheritedMethods, array $classMap): void
20212021
{
2022-
if ($this->type !== "class") {
2023-
return;
2024-
}
2025-
20262022
foreach ($this->extends as $parent) {
20272023
$parentInfo = $classMap[$parent->toString()] ?? null;
20282024
if (!$parentInfo) {
@@ -2033,7 +2029,7 @@ private function collectInheritedMembers(array &$parentsWithInheritedProperties,
20332029
$parentsWithInheritedProperties[$parent->toString()] = $parent;
20342030
}
20352031

2036-
if (!empty($parentInfo->funcInfos) && !isset($parentsWithInheritedMethods[$parent->toString()])) {
2032+
if (!isset($parentsWithInheritedMethods[$parent->toString()]) && $parentInfo->hasMethods()) {
20372033
$parentsWithInheritedMethods[$parent->toString()] = $parent;
20382034
}
20392035

@@ -2986,12 +2982,14 @@ function replaceClassSynopses(string $targetDirectory, array $classMap): array
29862982
$replacedXml = preg_replace(
29872983
[
29882984
"/REPLACED-ENTITY-([A-Za-z0-9._{}%-]+?;)/",
2985+
"/<phpdoc:(classref|exceptionref)\s+xmlns:phpdoc=\"([a-z0-9.:\/]+)\"\s+xmlns=\"([a-z0-9.:\/]+)\"\s+xml:id=\"([a-z0-9._-]+)\"\s*>/i",
29892986
"/<phpdoc:(classref|exceptionref)\s+xmlns:phpdoc=\"([a-z0-9.:\/]+)\"\s+xmlns=\"([a-z0-9.:\/]+)\"\s+xmlns:xi=\"([a-z0-9.:\/]+)\"\s+xml:id=\"([a-z0-9._-]+)\"\s*>/i",
29902987
"/<phpdoc:(classref|exceptionref)\s+xmlns:phpdoc=\"([a-z0-9.:\/]+)\"\s+xmlns=\"([a-z0-9.:\/]+)\"\s+xmlns:xlink=\"([a-z0-9.:\/]+)\"\s+xmlns:xi=\"([a-z0-9.:\/]+)\"\s+xml:id=\"([a-z0-9._-]+)\"\s*>/i",
29912988
"/<phpdoc:(classref|exceptionref)\s+xmlns=\"([a-z0-9.:\/]+)\"\s+xmlns:xlink=\"([a-z0-9.:\/]+)\"\s+xmlns:xi=\"([a-z0-9.:\/]+)\"\s+xmlns:phpdoc=\"([a-z0-9.:\/]+)\"\s+xml:id=\"([a-z0-9._-]+)\"\s*>/i",
29922989
],
29932990
[
29942991
"&$1",
2992+
"<phpdoc:$1 xml:id=\"$4\" xmlns:phpdoc=\"$2\" xmlns=\"$3\">",
29952993
"<phpdoc:$1 xml:id=\"$5\" xmlns:phpdoc=\"$2\" xmlns=\"$3\" xmlns:xi=\"$4\">",
29962994
"<phpdoc:$1 xml:id=\"$6\" xmlns:phpdoc=\"$2\" xmlns=\"$3\" xmlns:xlink=\"$4\" xmlns:xi=\"$5\">",
29972995
"<phpdoc:$1 xml:id=\"$6\" xmlns:phpdoc=\"$5\" xmlns=\"$2\" xmlns:xlink=\"$3\" xmlns:xi=\"$4\">",

0 commit comments

Comments
 (0)