-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix class synopsis generation #7891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. usually, inherited members of interfaces are also displayed in the manual |
||
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()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. on the other hand, constructors are usually not displayed as inherited members. |
||
$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\">", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a
readonly mixed
property which is indeed aresource
. On the contrary, the real type is displayed for params and returns because their PHPDoc type hint is usually invalid (e.g.true
,false|null
etc.)