Skip to content

Commit 7f1c77f

Browse files
committed
Fixes/Updates
1 parent 044ed2c commit 7f1c77f

File tree

5 files changed

+14
-7
lines changed

5 files changed

+14
-7
lines changed

UPGRADING

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ PHP 8.4 UPGRADE NOTES
2626
Consult sections 2. New Features and 6. New Functions for a list of
2727
newly implemented methods and constants.
2828
. Some DOM methods previously returned false or a PHP_ERR DOMException if a new
29-
node could not be allocated.
30-
They consistently throw an INVALID_STATE_ERR DOMException now.
29+
node could not be allocated. They consistently throw an INVALID_STATE_ERR
30+
DOMException now. This situation is extremely unlikely though and probably
31+
will not affect you. As a result DOMImplementation::createDocument() now has
32+
a tentative return type of DOMDocument instead of DOMDocument|false.
3133

3234
- PDO_DBLIB:
3335
. setAttribute, DBLIB_ATTR_STRINGIFY_UNIQUEIDENTIFIER and DBLIB_ATTR_DATETIME_CONVERT

ext/dom/domimplementation.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ PHP_METHOD(DOMImplementation, createDocument)
138138
RETURN_THROWS();
139139
}
140140
if (doctype->doc != NULL) {
141+
/* As the new document is the context node, and the default for strict error checking
142+
* is true, this will always throw. */
141143
php_dom_throw_error(WRONG_DOCUMENT_ERR, 1);
142144
RETURN_THROWS();
143145
}
@@ -172,6 +174,7 @@ PHP_METHOD(DOMImplementation, createDocument)
172174
if (localname != NULL) {
173175
xmlFree(localname);
174176
}
177+
/* See above for strict error checking argument. */
175178
php_dom_throw_error(INVALID_STATE_ERR, /* strict */ true);
176179
RETURN_THROWS();
177180
}

ext/dom/node.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,8 +700,10 @@ zend_result dom_node_prefix_write(dom_object *obj, zval *newval)
700700
}
701701
if (ns == NULL) {
702702
ns = xmlNewNs(nsnode, nodep->ns->href, (xmlChar *)prefix);
703+
/* Sadly, we cannot distinguish between OOM and namespace conflict.
704+
* But OOM will almost never happen. */
703705
if (UNEXPECTED(ns == NULL)) {
704-
php_dom_throw_error(INVALID_STATE_ERR, /* strict */ true);
706+
php_dom_throw_error(NAMESPACE_ERR, /* strict */ true);
705707
return FAILURE;
706708
}
707709
}

ext/dom/php_dom.stub.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,8 +477,8 @@ public function hasFeature(string $feature, string $version): bool {}
477477
/** @return DOMDocumentType|false */
478478
public function createDocumentType(string $qualifiedName, string $publicId = "", string $systemId = "") {}
479479

480-
/** @return DOMDocument|false */
481-
public function createDocument(?string $namespace = null, string $qualifiedName = "", ?DOMDocumentType $doctype = null) {}
480+
/** @tentative-return-type */
481+
public function createDocument(?string $namespace = null, string $qualifiedName = "", ?DOMDocumentType $doctype = null): DOMDocument {}
482482
}
483483

484484
/** @alias DOM\DocumentFragment */

ext/dom/php_dom_arginfo.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)