Fix return value in stub file for DOMNodeList::item

Not explicitly documenting the possibility of returning DOMElement causes
the Intelephense linter (a popular PHP linter with ~9 million downloads:
https://marketplace.visualstudio.com/items?itemName=bmewburn.vscode-intelephense-client)
to think this code is bad:

  $xp->query("whatever")->item(0)->getAttribute("foo");

DOMNode does not have getAttribute (while DOMElement does).
Documenting the DOMElement return type should fix Intelephense's linter.

Closes GH-11342.
This commit is contained in:
divinity76 2023-05-29 16:53:00 +02:00 committed by Niels Dossche
parent c473787abb
commit 761b9a44f8
3 changed files with 3 additions and 2 deletions

1
NEWS
View File

@ -10,6 +10,7 @@ PHP NEWS
and segfaults with replaceWith). (nielsdos)
. Fixed bug GH-10234 (Setting DOMAttr::textContent results in an empty
attribute value). (nielsdos)
. Fix return value in stub file for DOMNodeList::item. (divinity76)
- Opcache:
. Fix allocation loop in zend_shared_alloc_startup(). (nielsdos)

View File

@ -232,7 +232,7 @@ class DOMNodeList implements IteratorAggregate, Countable
public function getIterator(): Iterator {}
/** @return DOMNode|DOMNameSpaceNode|null */
/** @return DOMElement|DOMNode|DOMNameSpaceNode|null */
public function item(int $index) {}
}

View File

@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 74698bea9c5e0635cf91345e8512b9677489510c */
* Stub hash: a62e383b05df81ea245a7993215fb8ff4e1c7f9d */
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_dom_import_simplexml, 0, 1, DOMElement, 0)
ZEND_ARG_TYPE_INFO(0, node, IS_OBJECT, 0)