Skip to content

Commit 4c9892d

Browse files
committed
Fix class synopsis generation for interfaces
We have to generate <ooclass> elements for interfaces (rather than <oointerface>) in a number of places: directly inside the <classsynopsis> element and in the extends list.
1 parent f5cce2b commit 4c9892d

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

build/gen_stub.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,7 +1777,7 @@ public function getClassSynopsisElement(DOMDocument $doc, array $classMap): ?DOM
17771777
$classSynopsis = $doc->createElement("classsynopsis");
17781778
$classSynopsis->appendChild(new DOMText("\n "));
17791779

1780-
$ooElement = self::createOoElement($doc, $this, false, false, 4);
1780+
$ooElement = self::createOoElement($doc, $this, true, false, false, 4);
17811781
if (!$ooElement) {
17821782
return null;
17831783
}
@@ -1786,7 +1786,7 @@ public function getClassSynopsisElement(DOMDocument $doc, array $classMap): ?DOM
17861786

17871787
$classSynopsisInfo = $doc->createElement("classsynopsisinfo");
17881788
$classSynopsisInfo->appendChild(new DOMText("\n "));
1789-
$ooElement = self::createOoElement($doc, $this, true, false, 5);
1789+
$ooElement = self::createOoElement($doc, $this, false, true, false, 5);
17901790
if (!$ooElement) {
17911791
return null;
17921792
}
@@ -1800,7 +1800,14 @@ public function getClassSynopsisElement(DOMDocument $doc, array $classMap): ?DOM
18001800
throw new Exception("Missing parent class " . $parent->toString());
18011801
}
18021802

1803-
$ooElement = self::createOoElement($doc, $parentInfo, false, $k === 0 && $parentInfo->type === "class", 5);
1803+
$ooElement = self::createOoElement(
1804+
$doc,
1805+
$parentInfo,
1806+
$this->type === "interface",
1807+
false,
1808+
$k === 0,
1809+
5
1810+
);
18041811
if (!$ooElement) {
18051812
return null;
18061813
}
@@ -1815,7 +1822,7 @@ public function getClassSynopsisElement(DOMDocument $doc, array $classMap): ?DOM
18151822
throw new Exception("Missing implemented interface " . $interface->toString());
18161823
}
18171824

1818-
$ooElement = self::createOoElement($doc, $interfaceInfo, false, false, 5);
1825+
$ooElement = self::createOoElement($doc, $interfaceInfo, false, false, false, 5);
18191826
if (!$ooElement) {
18201827
return null;
18211828
}
@@ -1922,6 +1929,7 @@ public function getClassSynopsisElement(DOMDocument $doc, array $classMap): ?DOM
19221929
private static function createOoElement(
19231930
DOMDocument $doc,
19241931
ClassInfo $classInfo,
1932+
bool $overrideToClass,
19251933
bool $withModifiers,
19261934
bool $isExtends,
19271935
int $indentationLevel
@@ -1933,7 +1941,9 @@ private static function createOoElement(
19331941
return null;
19341942
}
19351943

1936-
$ooElement = $doc->createElement('oo' . $classInfo->type);
1944+
$type = $overrideToClass ? "class" : $classInfo->type;
1945+
1946+
$ooElement = $doc->createElement("oo$type");
19371947
$ooElement->appendChild(new DOMText("\n$indentation "));
19381948
if ($isExtends) {
19391949
$ooElement->appendChild($doc->createElement('modifier', 'extends'));
@@ -1949,7 +1959,7 @@ private static function createOoElement(
19491959
}
19501960
}
19511961

1952-
$nameElement = $doc->createElement($classInfo->type . 'name', $classInfo->name->toString());
1962+
$nameElement = $doc->createElement("{$type}name", $classInfo->name->toString());
19531963
$ooElement->appendChild($nameElement);
19541964
$ooElement->appendChild(new DOMText("\n$indentation"));
19551965

0 commit comments

Comments
 (0)