### Description The following code: ```php <?php $root = simplexml_load_string('<?xml version="1.0"?> <root xmlns:reserved="reserved-ns" xmlns:special="special-ns"> <child reserved:attribute="Sample" special:attribute="Test" /> </root> '); $spattr = $root->child->attributes('special-ns'); var_dump(Dom\import_simplexml($spattr)); ?> ``` Resulted in this output: ``` object(Dom\Attr)#2 (22) { ["namespaceURI"]=> string(10) "special-ns" ["prefix"]=> string(7) "special" ["localName"]=> string(9) "attribute" ["name"]=> string(17) "special:attribute" ["value"]=> string(4) "Test" ["ownerElement"]=> string(22) "(object value omitted)" ["specified"]=> bool(true) ["nodeName"]=> string(17) "special:attribute" ["nodeValue"]=> string(4) "Test" ["nodeType"]=> int(2) ["parentNode"]=> string(22) "(object value omitted)" ["parentElement"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> string(22) "(object value omitted)" ["lastChild"]=> string(22) "(object value omitted)" ["previousSibling"]=> string(22) "(object value omitted)" ["nextSibling"]=> NULL ["attributes"]=> NULL ["isConnected"]=> bool(true) ["ownerDocument"]=> string(22) "(object value omitted)" ["baseURI"]=> string(11) "about:blank" ["textContent"]=> string(4) "Test" } ``` But I expected this output instead: ``` Fatal error: Dom\import_simplexml(): Return value must be of type Dom\Element, Dom\Attr returned in Unknown on line 0 ``` To reproduce: ``` -d "zend_extension=/php-src/modules/opcache.so" -d "opcache.enable=1" -d "opcache.enable_cli=1" -d "opcache.jit=1215" ``` ### PHP Version nightly ### Operating System ubuntu 22.04
Activity
ndossche commentedon Oct 17, 2024
dom_import_simplexmlhas this issue too. It's been wrong since PHP 8.0 at least, and the signature was inherited in 8.4-dev.[-]Unexpected result from Dom\import_simplexml in JIT[/-][+]dom_import_simplexml stub is wrong[/+]Fix phpGH-16473: dom_import_simplexml stub is wrong
Fix GH-16473: dom_import_simplexml stub is wrong
Merge branch 'PHP-8.2' into PHP-8.3
Merge branch 'PHP-8.3' into PHP-8.4
Merge branch 'PHP-8.4'