Skip to content

Commit b9e8d93

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: Fix class synopsis generation
2 parents c70f3e0 + 0462719 commit b9e8d93

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
@@ -1548,9 +1548,9 @@ public function getFieldSynopsisElement(DOMDocument $doc): DOMElement
15481548
$fieldsynopsisElement->appendChild(new DOMText("\n "));
15491549
$fieldsynopsisElement->appendChild($this->getFieldSynopsisType()->getTypeForDoc($doc));
15501550

1551-
$className = str_replace("\\", "-", $this->name->class->toLowerString());
1551+
$className = str_replace(["\\", "_"], ["-", "-"], $this->name->class->toLowerString());
15521552
$varnameElement = $doc->createElement("varname", $this->name->property);
1553-
$varnameElement->setAttribute("linkend", "$className.props." . strtolower($this->name->property));
1553+
$varnameElement->setAttribute("linkend", "$className.props." . strtolower(str_replace("_", "-", $this->name->property)));
15541554
$fieldsynopsisElement->appendChild(new DOMText("\n "));
15551555
$fieldsynopsisElement->appendChild($varnameElement);
15561556

@@ -1566,14 +1566,14 @@ public function getFieldSynopsisElement(DOMDocument $doc): DOMElement
15661566
}
15671567

15681568
private function getFieldSynopsisType(): Type {
1569-
if ($this->type) {
1570-
return $this->type;
1571-
}
1572-
15731569
if ($this->phpDocType) {
15741570
return $this->phpDocType;
15751571
}
15761572

1573+
if ($this->type) {
1574+
return $this->type;
1575+
}
1576+
15771577
throw new Exception("A property must have a type");
15781578
}
15791579

@@ -2013,11 +2013,11 @@ private static function createOoElement(
20132013
}
20142014

20152015
public static function getClassSynopsisFilename(Name $name): string {
2016-
return strtolower(implode('-', $name->parts));
2016+
return strtolower(str_replace("_", "-", implode('-', $name->parts)));
20172017
}
20182018

20192019
public static function getClassSynopsisReference(Name $name): string {
2020-
return "class." . strtolower(implode('-', $name->parts));
2020+
return "class." . self::getClassSynopsisFilename($name);
20212021
}
20222022

20232023
/**
@@ -2027,10 +2027,6 @@ public static function getClassSynopsisReference(Name $name): string {
20272027
*/
20282028
private function collectInheritedMembers(array &$parentsWithInheritedProperties, array &$parentsWithInheritedMethods, array $classMap): void
20292029
{
2030-
if ($this->type !== "class") {
2031-
return;
2032-
}
2033-
20342030
foreach ($this->extends as $parent) {
20352031
$parentInfo = $classMap[$parent->toString()] ?? null;
20362032
if (!$parentInfo) {
@@ -2041,7 +2037,7 @@ private function collectInheritedMembers(array &$parentsWithInheritedProperties,
20412037
$parentsWithInheritedProperties[$parent->toString()] = $parent;
20422038
}
20432039

2044-
if (!empty($parentInfo->funcInfos) && !isset($parentsWithInheritedMethods[$parent->toString()])) {
2040+
if (!isset($parentsWithInheritedMethods[$parent->toString()]) && $parentInfo->hasMethods()) {
20452041
$parentsWithInheritedMethods[$parent->toString()] = $parent;
20462042
}
20472043

@@ -2998,12 +2994,14 @@ function replaceClassSynopses(string $targetDirectory, array $classMap): array
29982994
$replacedXml = preg_replace(
29992995
[
30002996
"/REPLACED-ENTITY-([A-Za-z0-9._{}%-]+?;)/",
2997+
"/<phpdoc:(classref|exceptionref)\s+xmlns:phpdoc=\"([a-z0-9.:\/]+)\"\s+xmlns=\"([a-z0-9.:\/]+)\"\s+xml:id=\"([a-z0-9._-]+)\"\s*>/i",
30012998
"/<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",
30022999
"/<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",
30033000
"/<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",
30043001
],
30053002
[
30063003
"&$1",
3004+
"<phpdoc:$1 xml:id=\"$4\" xmlns:phpdoc=\"$2\" xmlns=\"$3\">",
30073005
"<phpdoc:$1 xml:id=\"$5\" xmlns:phpdoc=\"$2\" xmlns=\"$3\" xmlns:xi=\"$4\">",
30083006
"<phpdoc:$1 xml:id=\"$6\" xmlns:phpdoc=\"$2\" xmlns=\"$3\" xmlns:xlink=\"$4\" xmlns:xi=\"$5\">",
30093007
"<phpdoc:$1 xml:id=\"$6\" xmlns:phpdoc=\"$5\" xmlns=\"$2\" xmlns:xlink=\"$3\" xmlns:xi=\"$4\">",

0 commit comments

Comments
 (0)