From 607a367886f5e0db2183b28c8a1a44b577a18c57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Mon, 22 Nov 2021 07:33:07 +0100 Subject: [PATCH] Fix class synopsis generation --- build/gen_stub.php | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/build/gen_stub.php b/build/gen_stub.php index 5f74d26dbc37d..4e7a3cbb3c2c4 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -1540,9 +1540,9 @@ public function getFieldSynopsisElement(DOMDocument $doc): DOMElement $fieldsynopsisElement->appendChild(new DOMText("\n ")); $fieldsynopsisElement->appendChild($this->getFieldSynopsisType()->getTypeForDoc($doc)); - $className = str_replace("\\", "-", $this->name->class->toLowerString()); + $className = str_replace(["\\", "_"], ["-", "-"], $this->name->class->toLowerString()); $varnameElement = $doc->createElement("varname", $this->name->property); - $varnameElement->setAttribute("linkend", "$className.props." . strtolower($this->name->property)); + $varnameElement->setAttribute("linkend", "$className.props." . strtolower(str_replace("_", "-", $this->name->property))); $fieldsynopsisElement->appendChild(new DOMText("\n ")); $fieldsynopsisElement->appendChild($varnameElement); @@ -1558,14 +1558,14 @@ public function getFieldSynopsisElement(DOMDocument $doc): DOMElement } private function getFieldSynopsisType(): Type { - if ($this->type) { - return $this->type; - } - if ($this->phpDocType) { return $this->phpDocType; } + if ($this->type) { + return $this->type; + } + throw new Exception("A property must have a type"); } @@ -2005,11 +2005,11 @@ private static function createOoElement( } public static function getClassSynopsisFilename(Name $name): string { - return strtolower(implode('-', $name->parts)); + return strtolower(str_replace("_", "-", implode('-', $name->parts))); } public static function getClassSynopsisReference(Name $name): string { - return "class." . strtolower(implode('-', $name->parts)); + return "class." . self::getClassSynopsisFilename($name); } /** @@ -2019,10 +2019,6 @@ public static function getClassSynopsisReference(Name $name): string { */ private function collectInheritedMembers(array &$parentsWithInheritedProperties, array &$parentsWithInheritedMethods, array $classMap): void { - if ($this->type !== "class") { - return; - } - foreach ($this->extends as $parent) { $parentInfo = $classMap[$parent->toString()] ?? null; if (!$parentInfo) { @@ -2033,7 +2029,7 @@ private function collectInheritedMembers(array &$parentsWithInheritedProperties, $parentsWithInheritedProperties[$parent->toString()] = $parent; } - if (!empty($parentInfo->funcInfos) && !isset($parentsWithInheritedMethods[$parent->toString()])) { + if (!isset($parentsWithInheritedMethods[$parent->toString()]) && $parentInfo->hasMethods()) { $parentsWithInheritedMethods[$parent->toString()] = $parent; } @@ -2986,12 +2982,14 @@ function replaceClassSynopses(string $targetDirectory, array $classMap): array $replacedXml = preg_replace( [ "/REPLACED-ENTITY-([A-Za-z0-9._{}%-]+?;)/", + "//i", "//i", "//i", "//i", ], [ "&$1", + "", "", "", "",