mirror of
https://github.com/php/php-src.git
synced 2024-11-24 10:24:11 +08:00
Fix class synopsis generation
Closes GH-7891
This commit is contained in:
parent
46bec6de42
commit
0462719999
@ -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\">",
|
||||
|
Loading…
Reference in New Issue
Block a user