Skip to content

Commit a89adc8

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 8aedf6d commit a89adc8

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
@@ -2668,41 +2668,35 @@ protected function getFieldSynopsisValueString(array $allConstInfos): ?string
26682668
return $this->valueString;
26692669
}
26702670

2671-
public function getPredefinedConstantTerm(DOMDocument $doc, int $indentationLevel): DOMElement {
2671+
private function getPredefinedConstantElement(
2672+
DOMDocument $doc,
2673+
int $indentationLevel,
2674+
string $name
2675+
): DOMElement {
26722676
$indentation = str_repeat(" ", $indentationLevel);
26732677

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

26762680
$constantElement = $doc->createElement("constant");
26772681
$constantElement->textContent = $this->name->__toString();
26782682

26792683
$typeElement = ($this->phpDocType ?? $this->type)->getTypeForDoc($doc);
26802684

2681-
$termElement->appendChild(new DOMText("\n$indentation "));
2682-
$termElement->appendChild($constantElement);
2683-
$termElement->appendChild(new DOMText("\n$indentation ("));
2684-
$termElement->appendChild($typeElement);
2685-
$termElement->appendChild(new DOMText(")\n$indentation"));
2685+
$element->appendChild(new DOMText("\n$indentation "));
2686+
$element->appendChild($constantElement);
2687+
$element->appendChild(new DOMText("\n$indentation ("));
2688+
$element->appendChild($typeElement);
2689+
$element->appendChild(new DOMText(")\n$indentation"));
26862690

2687-
return $termElement;
2691+
return $element;
26882692
}
26892693

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

2705-
return $entryElement;
2698+
public function getPredefinedConstantEntry(DOMDocument $doc, int $indentationLevel): DOMElement {
2699+
return $this->getPredefinedConstantElement($doc, $indentationLevel, "entry");
27062700
}
27072701

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

0 commit comments

Comments
 (0)