Fix class synopsis generation

Closes GH-7891
This commit is contained in:
Máté Kocsis 2021-11-22 07:33:07 +01:00
parent 46bec6de42
commit 0462719999
No known key found for this signature in database
GPG Key ID: FD055E41728BF310

View File

@ -1540,9 +1540,9 @@ class PropertyInfo
$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 @@ class PropertyInfo
}
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 @@ class ClassInfo {
}
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 @@ class ClassInfo {
*/
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 @@ class ClassInfo {
$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._{}%-]+?;)/",
"/<phpdoc:(classref|exceptionref)\s+xmlns:phpdoc=\"([a-z0-9.:\/]+)\"\s+xmlns=\"([a-z0-9.:\/]+)\"\s+xml:id=\"([a-z0-9._-]+)\"\s*>/i",
"/<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",
"/<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",
"/<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",
],
[
"&$1",
"<phpdoc:$1 xml:id=\"$4\" xmlns:phpdoc=\"$2\" xmlns=\"$3\">",
"<phpdoc:$1 xml:id=\"$5\" xmlns:phpdoc=\"$2\" xmlns=\"$3\" xmlns:xi=\"$4\">",
"<phpdoc:$1 xml:id=\"$6\" xmlns:phpdoc=\"$2\" xmlns=\"$3\" xmlns:xlink=\"$4\" xmlns:xi=\"$5\">",
"<phpdoc:$1 xml:id=\"$6\" xmlns:phpdoc=\"$5\" xmlns=\"$2\" xmlns:xlink=\"$3\" xmlns:xi=\"$4\">",