Skip to content

Commit 74f7ecb

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 5ae87ff commit 74f7ecb

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
@@ -2672,41 +2672,35 @@ protected function getFieldSynopsisValueString(array $allConstInfos): ?string
26722672
return $this->valueString;
26732673
}
26742674

2675-
public function getPredefinedConstantTerm(DOMDocument $doc, int $indentationLevel): DOMElement {
2675+
private function getPredefinedConstantElement(
2676+
DOMDocument $doc,
2677+
int $indentationLevel,
2678+
string $name
2679+
): DOMElement {
26762680
$indentation = str_repeat(" ", $indentationLevel);
26772681

2678-
$termElement = $doc->createElement("term");
2682+
$element = $doc->createElement($name);
26792683

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

26832687
$typeElement = ($this->phpDocType ?? $this->type)->getTypeForDoc($doc);
26842688

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

2691-
return $termElement;
2695+
return $element;
26922696
}
26932697

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

2709-
return $entryElement;
2702+
public function getPredefinedConstantEntry(DOMDocument $doc, int $indentationLevel): DOMElement {
2703+
return $this->getPredefinedConstantElement($doc, $indentationLevel, "entry");
27102704
}
27112705

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

0 commit comments

Comments
 (0)