From 632ebcc03d7fcff2d30b0a8b422cca5943cc35ba 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. --- ext/dom/php_dom.stub.php | 2 +- ext/dom/php_dom_arginfo.h | 4 ++-- ext/dom/tests/gh16473.phpt | 13 +++++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 ext/dom/tests/gh16473.phpt diff --git a/ext/dom/php_dom.stub.php b/ext/dom/php_dom.stub.php index 0ed7b4544a501..ea80d206bb352 100644 --- a/ext/dom/php_dom.stub.php +++ b/ext/dom/php_dom.stub.php @@ -933,4 +933,4 @@ public function registerPhpFunctions(string|array|null $restrict = null): void { } #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 6aa7f2eb8a388..de1e201fc1e8d 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 0000000000000..f4f7308ca901c --- /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"