Skip to content

Commit 8aca966

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 5c786ba commit 8aca966

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
@@ -2658,41 +2658,35 @@ protected function getFieldSynopsisValueString(array $allConstInfos): ?string
26582658
return $this->valueString;
26592659
}
26602660

2661-
public function getPredefinedConstantTerm(DOMDocument $doc, int $indentationLevel): DOMElement {
2661+
private function getPredefinedConstantElement(
2662+
DOMDocument $doc,
2663+
int $indentationLevel,
2664+
string $name
2665+
): DOMElement {
26622666
$indentation = str_repeat(" ", $indentationLevel);
26632667

2664-
$termElement = $doc->createElement("term");
2668+
$element = $doc->createElement($name);
26652669

26662670
$constantElement = $doc->createElement("constant");
26672671
$constantElement->textContent = $this->name->__toString();
26682672

26692673
$typeElement = ($this->phpDocType ?? $this->type)->getTypeForDoc($doc);
26702674

2671-
$termElement->appendChild(new DOMText("\n$indentation "));
2672-
$termElement->appendChild($constantElement);
2673-
$termElement->appendChild(new DOMText("\n$indentation ("));
2674-
$termElement->appendChild($typeElement);
2675-
$termElement->appendChild(new DOMText(")\n$indentation"));
2675+
$element->appendChild(new DOMText("\n$indentation "));
2676+
$element->appendChild($constantElement);
2677+
$element->appendChild(new DOMText("\n$indentation ("));
2678+
$element->appendChild($typeElement);
2679+
$element->appendChild(new DOMText(")\n$indentation"));
26762680

2677-
return $termElement;
2681+
return $element;
26782682
}
26792683

2680-
public function getPredefinedConstantEntry(DOMDocument $doc, int $indentationLevel): DOMElement {
2681-
$indentation = str_repeat(" ", $indentationLevel);
2682-
2683-
$entryElement = $doc->createElement("entry");
2684-
2685-
$constantElement = $doc->createElement("constant");
2686-
$constantElement->textContent = $this->name->__toString();
2687-
$typeElement = ($this->phpDocType ?? $this->type)->getTypeForDoc($doc);
2688-
2689-
$entryElement->appendChild(new DOMText("\n$indentation "));
2690-
$entryElement->appendChild($constantElement);
2691-
$entryElement->appendChild(new DOMText("\n$indentation ("));
2692-
$entryElement->appendChild($typeElement);
2693-
$entryElement->appendChild(new DOMText(")\n$indentation"));
2684+
public function getPredefinedConstantTerm(DOMDocument $doc, int $indentationLevel): DOMElement {
2685+
return $this->getPredefinedConstantElement($doc, $indentationLevel, "term");
2686+
}
26942687

2695-
return $entryElement;
2688+
public function getPredefinedConstantEntry(DOMDocument $doc, int $indentationLevel): DOMElement {
2689+
return $this->getPredefinedConstantElement($doc, $indentationLevel, "entry");
26962690
}
26972691

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

0 commit comments

Comments
 (0)