diff --git a/Zend/zend_constants.stub.php b/Zend/zend_constants.stub.php index f28a50ea6fd..014ae748f3a 100644 --- a/Zend/zend_constants.stub.php +++ b/Zend/zend_constants.stub.php @@ -121,9 +121,18 @@ const ZEND_DEBUG_BUILD = UNKNOWN; /* Special constants true/false/null. */ -/** @var bool */ +/** + * @var bool + * @undocumentable + */ const TRUE = true; -/** @var bool */ +/** + * @var bool + * @undocumentable + */ const FALSE = false; -/** @var null */ +/** + * @var null + * @undocumentable + */ const NULL = null; diff --git a/Zend/zend_constants_arginfo.h b/Zend/zend_constants_arginfo.h index c2b24c2edc4..e19d478aa20 100644 --- a/Zend/zend_constants_arginfo.h +++ b/Zend/zend_constants_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: df76f4e5a735baba96c4ac3538e9e3e48d934f0f */ + * Stub hash: 1da352eeafa0d33ddda4171cca4c7bf18313915f */ diff --git a/build/gen_stub.php b/build/gen_stub.php index 6605d2d2478..14fd822b3e5 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -2058,7 +2058,6 @@ class ConstInfo extends VariableLike $constantElement->textContent = $this->name->__toString(); $typeElement = ($this->phpDocType ?? $this->type)->getTypeForDoc($doc); - $stubConstantType = $constantElement->textContent; $termElement->appendChild(new DOMText("\n$indentation ")); $termElement->appendChild($constantElement); @@ -2069,6 +2068,24 @@ class ConstInfo extends VariableLike return $termElement; } + public function getPredefinedConstantEntry(DOMDocument $doc, int $indentationLevel): DOMElement { + $indentation = str_repeat(" ", $indentationLevel); + + $entryElement = $doc->createElement("entry"); + + $constantElement = $doc->createElement("constant"); + $constantElement->textContent = $this->name->__toString(); + $typeElement = ($this->phpDocType ?? $this->type)->getTypeForDoc($doc); + + $entryElement->appendChild(new DOMText("\n$indentation ")); + $entryElement->appendChild($constantElement); + $entryElement->appendChild(new DOMText("\n$indentation (")); + $entryElement->appendChild($typeElement); + $entryElement->appendChild(new DOMText(")\n$indentation")); + + return $entryElement; + } + public function discardInfoForOldPhpVersions(): void { $this->type = null; $this->flags &= ~Class_::MODIFIER_FINAL; @@ -4510,7 +4527,7 @@ function replacePredefinedConstants(string $targetDirectory, array $constMap, ar foreach ($it as $file) { $pathName = $file->getPathName(); - if (!preg_match('/constants\.xml$/i', $pathName)) { + if (!preg_match('/(?:[\w\.]*constants[\w\.]*|tokens|filters).xml$/i', basename($pathName))) { continue; } @@ -4519,7 +4536,7 @@ function replacePredefinedConstants(string $targetDirectory, array $constMap, ar continue; } - if (stripos($xml, "getElementsByTagName("term"); - $manualTermElement = $list->item(0); - if (!$manualTermElement instanceof DOMElement) { + foreach ($entry->getElementsByTagName("term") as $manualTermElement) { + $manualConstantElement = $manualTermElement->getElementsByTagName("constant")->item(0); + if (!$manualConstantElement instanceof DOMElement) { + continue; + } + + $manualConstantName = $manualConstantElement->textContent; + + $stubConstant = $constMap[$manualConstantName] ?? null; + if ($stubConstant === null) { + continue; + } + + $documentedConstMap[$manualConstantName] = $manualConstantName; + + if ($entry->firstChild instanceof DOMText) { + $indentationLevel = strlen(str_replace("\n", "", $entry->firstChild->textContent)); + } else { + $indentationLevel = 3; + } + $newTermElement = $stubConstant->getPredefinedConstantTerm($doc, $indentationLevel); + + if ($manualTermElement->textContent === $newTermElement->textContent) { + continue; + } + + $manualTermElement->parentNode->replaceChild($newTermElement, $manualTermElement); + } + } + + foreach ($doc->getElementsByTagName("row") as $row) { + if (!$row instanceof DOMElement) { continue; } - $list = $manualTermElement->getElementsByTagName("constant"); - $manualConstantElement = $list->item(0); - if (!$manualConstantElement instanceof DOMElement) { - continue; - } - $manualConstantName = $manualConstantElement->textContent; - - $stubConstant = $constMap[$manualConstantName] ?? null; - if ($stubConstant === null) { + $entry = $row->getElementsByTagName("entry")->item(0); + if (!$entry instanceof DOMElement) { continue; } - $documentedConstMap[$manualConstantName] = $manualConstantName; + foreach ($entry->getElementsByTagName("constant") as $manualConstantElement) { + if (!$manualConstantElement instanceof DOMElement) { + continue; + } - if ($entry->firstChild instanceof DOMText) { - $indentationLevel = strlen(str_replace("\n", "", $entry->firstChild->textContent)); - } else { - $indentationLevel = 3; + $manualConstantName = $manualConstantElement->textContent; + + $stubConstant = $constMap[$manualConstantName] ?? null; + if ($stubConstant === null) { + continue; + } + + $documentedConstMap[$manualConstantName] = $manualConstantName; + + if ($row->firstChild instanceof DOMText) { + $indentationLevel = strlen(str_replace("\n", "", $row->firstChild->textContent)); + } else { + $indentationLevel = 3; + } + $newEntryElement = $stubConstant->getPredefinedConstantEntry($doc, $indentationLevel); + + if ($entry->textContent === $newEntryElement->textContent) { + continue; + } + + $entry->parentNode->replaceChild($newEntryElement, $entry); + $updated = true; } - $newTermElement = $stubConstant->getPredefinedConstantTerm($doc, $indentationLevel); - - if ($manualTermElement->textContent === $newTermElement->textContent) { - continue; - } - - $manualTermElement->parentNode->replaceChild($newTermElement, $manualTermElement); - $updated = true; } if ($updated) { @@ -4871,8 +4923,7 @@ function replaceMethodSynopses( continue; } - $list = $methodSynopsis->getElementsByTagName("methodname"); - $item = $list->item(0); + $item = $methodSynopsis->getElementsByTagName("methodname")->item(0); if (!$item instanceof DOMElement) { continue; }