From 0a3b2ee272fbbf88a8860903943d9906ec8f769d Mon Sep 17 00:00:00 2001 From: Matteo Beccati Date: Thu, 29 Jan 2026 12:10:25 +0100 Subject: [PATCH] Fixed GH-21077. Fixed stub for Dom\Node::baseURI --- ext/dom/php_dom.stub.php | 2 +- ext/dom/php_dom_arginfo.h | 4 ++-- ext/dom/tests/node_baseuri_null.phpt | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 ext/dom/tests/node_baseuri_null.phpt diff --git a/ext/dom/php_dom.stub.php b/ext/dom/php_dom.stub.php index 81713403e0e0..d09eb62feb2e 100644 --- a/ext/dom/php_dom.stub.php +++ b/ext/dom/php_dom.stub.php @@ -1372,7 +1372,7 @@ private final function __construct() {} * @readonly * @virtual */ - public string $baseURI; + public ?string $baseURI; /** * @readonly diff --git a/ext/dom/php_dom_arginfo.h b/ext/dom/php_dom_arginfo.h index ea42d6de4980..215492c86e26 100644 --- a/ext/dom/php_dom_arginfo.h +++ b/ext/dom/php_dom_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: d8a9d33a072c3c9e3798be5eee1833163a18f441 */ + * Stub hash: 32f89cefa4054e430f07940aad3556865f497b89 */ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_dom_import_simplexml, 0, 1, DOMAttr|DOMElement, 0) ZEND_ARG_TYPE_INFO(0, node, IS_OBJECT, 0) @@ -2805,7 +2805,7 @@ static zend_class_entry *register_class_Dom_Node(void) zval property_baseURI_default_value; ZVAL_UNDEF(&property_baseURI_default_value); zend_string *property_baseURI_name = zend_string_init("baseURI", sizeof("baseURI") - 1, 1); - zend_declare_typed_property(class_entry, property_baseURI_name, &property_baseURI_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); + zend_declare_typed_property(class_entry, property_baseURI_name, &property_baseURI_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); zend_string_release(property_baseURI_name); zval property_isConnected_default_value; diff --git a/ext/dom/tests/node_baseuri_null.phpt b/ext/dom/tests/node_baseuri_null.phpt new file mode 100644 index 000000000000..d12b3ca612d6 --- /dev/null +++ b/ext/dom/tests/node_baseuri_null.phpt @@ -0,0 +1,14 @@ +--TEST-- +DOMNode::baseURI can be NULL +--EXTENSIONS-- +dom +--FILE-- +createDocumentType('html', 'publicId', 'systemId'); + +var_dump($node->baseURI); + +--EXPECT-- +NULL