Skip to content

Commit

Permalink
Fix class synopsis generation for interfaces
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kocsismate committed Sep 8, 2021
1 parent f5cce2b commit 4c9892d
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions build/gen_stub.php
Expand Up @@ -1777,7 +1777,7 @@ public function getClassSynopsisElement(DOMDocument $doc, array $classMap): ?DOM
$classSynopsis = $doc->createElement("classsynopsis");
$classSynopsis->appendChild(new DOMText("\n "));

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

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

$ooElement = self::createOoElement($doc, $parentInfo, false, $k === 0 && $parentInfo->type === "class", 5);
$ooElement = self::createOoElement(
$doc,
$parentInfo,
$this->type === "interface",
false,
$k === 0,
5
);
if (!$ooElement) {
return null;
}
Expand All @@ -1815,7 +1822,7 @@ public function getClassSynopsisElement(DOMDocument $doc, array $classMap): ?DOM
throw new Exception("Missing implemented interface " . $interface->toString());
}

$ooElement = self::createOoElement($doc, $interfaceInfo, false, false, 5);
$ooElement = self::createOoElement($doc, $interfaceInfo, false, false, false, 5);
if (!$ooElement) {
return null;
}
Expand Down Expand Up @@ -1922,6 +1929,7 @@ public function getClassSynopsisElement(DOMDocument $doc, array $classMap): ?DOM
private static function createOoElement(
DOMDocument $doc,
ClassInfo $classInfo,
bool $overrideToClass,
bool $withModifiers,
bool $isExtends,
int $indentationLevel
Expand All @@ -1933,7 +1941,9 @@ private static function createOoElement(
return null;
}

$ooElement = $doc->createElement('oo' . $classInfo->type);
$type = $overrideToClass ? "class" : $classInfo->type;

$ooElement = $doc->createElement("oo$type");
$ooElement->appendChild(new DOMText("\n$indentation "));
if ($isExtends) {
$ooElement->appendChild($doc->createElement('modifier', 'extends'));
Expand All @@ -1949,7 +1959,7 @@ private static function createOoElement(
}
}

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

Expand Down

0 comments on commit 4c9892d

Please sign in to comment.