From 41af9335b7fa90f63b48e2c962e5d183016f5963 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Thu, 17 Oct 2024 21:35:50 +0200 Subject: [PATCH] Fix GH-16473: dom_import_simplexml stub is wrong It's been wrong since PHP 8.0 at least, and the signature was inherited in 8.4-dev to the new DOM methods. Closes GH-16489. --- NEWS | 1 + ext/dom/php_dom.stub.php | 2 +- ext/dom/php_dom_arginfo.h | 4 ++-- ext/dom/tests/gh16473.phpt | 13 +++++++++++++ 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 ext/dom/tests/gh16473.phpt diff --git a/NEWS b/NEWS index 9a3d6fa01f0..103b778aacf 100644 --- a/NEWS +++ b/NEWS @@ -21,6 +21,7 @@ PHP NEWS - DOM: . Fixed bug GH-16316 (DOMXPath breaks when not initialized properly). (nielsdos) + . Fixed bug GH-16473 (dom_import_simplexml stub is wrong). (nielsdos) - EXIF: . Fixed bug GH-16409 (Segfault in exif_thumbnail when not dealing with a diff --git a/ext/dom/php_dom.stub.php b/ext/dom/php_dom.stub.php index 0ed7b4544a5..ea80d206bb3 100644 --- a/ext/dom/php_dom.stub.php +++ b/ext/dom/php_dom.stub.php @@ -933,4 +933,4 @@ class DOMXPath } #endif -function dom_import_simplexml(object $node): DOMElement {} +function dom_import_simplexml(object $node): DOMAttr|DOMElement {} diff --git a/ext/dom/php_dom_arginfo.h b/ext/dom/php_dom_arginfo.h index 6aa7f2eb8a3..de1e201fc1e 100644 --- a/ext/dom/php_dom_arginfo.h +++ b/ext/dom/php_dom_arginfo.h @@ -1,7 +1,7 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 7d4dc9e1a3736f2ac9082c32bf5260dfa58b1aa0 */ + * Stub hash: 6d1c16a61f23de241f72f3559a9987d2f4a9c6fd */ -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_dom_import_simplexml, 0, 1, DOMElement, 0) +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) ZEND_END_ARG_INFO() diff --git a/ext/dom/tests/gh16473.phpt b/ext/dom/tests/gh16473.phpt new file mode 100644 index 00000000000..f4f7308ca90 --- /dev/null +++ b/ext/dom/tests/gh16473.phpt @@ -0,0 +1,13 @@ +--TEST-- +GH-16473 (dom_import_simplexml stub is wrong) +--EXTENSIONS-- +dom +simplexml +--FILE-- +'); +$attr = $root->attributes('urn:x'); +var_dump(dom_import_simplexml($attr)->textContent); +?> +--EXPECT-- +string(3) "foo"