Skip to content

Commit 48acabf

Browse files
gen_stub: add ConstInfo::getPredefinedConstantElement()
Simplifies the implementation of `::getPredefinedConstantTerm()` and `::getPredefinedConstantEntry()`, which only differ in the name of the tag used.
1 parent 2657f5a commit 48acabf

File tree

1 file changed

+17
-23
lines changed

1 file changed

+17
-23
lines changed

build/gen_stub.php

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2674,41 +2674,35 @@ protected function getFieldSynopsisValueString(array $allConstInfos): ?string
26742674
return $this->valueString;
26752675
}
26762676

2677-
public function getPredefinedConstantTerm(DOMDocument $doc, int $indentationLevel): DOMElement {
2677+
private function getPredefinedConstantElement(
2678+
DOMDocument $doc,
2679+
int $indentationLevel,
2680+
string $name
2681+
): DOMElement {
26782682
$indentation = str_repeat(" ", $indentationLevel);
26792683

2680-
$termElement = $doc->createElement("term");
2684+
$element = $doc->createElement($name);
26812685

26822686
$constantElement = $doc->createElement("constant");
26832687
$constantElement->textContent = $this->name->__toString();
26842688

26852689
$typeElement = ($this->phpDocType ?? $this->type)->getTypeForDoc($doc);
26862690

2687-
$termElement->appendChild(new DOMText("\n$indentation "));
2688-
$termElement->appendChild($constantElement);
2689-
$termElement->appendChild(new DOMText("\n$indentation ("));
2690-
$termElement->appendChild($typeElement);
2691-
$termElement->appendChild(new DOMText(")\n$indentation"));
2691+
$element->appendChild(new DOMText("\n$indentation "));
2692+
$element->appendChild($constantElement);
2693+
$element->appendChild(new DOMText("\n$indentation ("));
2694+
$element->appendChild($typeElement);
2695+
$element->appendChild(new DOMText(")\n$indentation"));
26922696

2693-
return $termElement;
2697+
return $element;
26942698
}
26952699

2696-
public function getPredefinedConstantEntry(DOMDocument $doc, int $indentationLevel): DOMElement {
2697-
$indentation = str_repeat(" ", $indentationLevel);
2698-
2699-
$entryElement = $doc->createElement("entry");
2700-
2701-
$constantElement = $doc->createElement("constant");
2702-
$constantElement->textContent = $this->name->__toString();
2703-
$typeElement = ($this->phpDocType ?? $this->type)->getTypeForDoc($doc);
2704-
2705-
$entryElement->appendChild(new DOMText("\n$indentation "));
2706-
$entryElement->appendChild($constantElement);
2707-
$entryElement->appendChild(new DOMText("\n$indentation ("));
2708-
$entryElement->appendChild($typeElement);
2709-
$entryElement->appendChild(new DOMText(")\n$indentation"));
2700+
public function getPredefinedConstantTerm(DOMDocument $doc, int $indentationLevel): DOMElement {
2701+
return $this->getPredefinedConstantElement($doc, $indentationLevel, "term");
2702+
}
27102703

2711-
return $entryElement;
2704+
public function getPredefinedConstantEntry(DOMDocument $doc, int $indentationLevel): DOMElement {
2705+
return $this->getPredefinedConstantElement($doc, $indentationLevel, "entry");
27122706
}
27132707

27142708
public function discardInfoForOldPhpVersions(?int $phpVersionIdMinimumCompatibility): void {

0 commit comments

Comments
 (0)