Skip to content

Commit 761b9a4

Browse files
divinity76nielsdos
authored andcommitted
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.
1 parent c473787 commit 761b9a4

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ PHP NEWS
1010
and segfaults with replaceWith). (nielsdos)
1111
. Fixed bug GH-10234 (Setting DOMAttr::textContent results in an empty
1212
attribute value). (nielsdos)
13+
. Fix return value in stub file for DOMNodeList::item. (divinity76)
1314

1415
- Opcache:
1516
. Fix allocation loop in zend_shared_alloc_startup(). (nielsdos)

ext/dom/php_dom.stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public function count(): int {}
232232

233233
public function getIterator(): Iterator {}
234234

235-
/** @return DOMNode|DOMNameSpaceNode|null */
235+
/** @return DOMElement|DOMNode|DOMNameSpaceNode|null */
236236
public function item(int $index) {}
237237
}
238238

ext/dom/php_dom_arginfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 74698bea9c5e0635cf91345e8512b9677489510c */
2+
* Stub hash: a62e383b05df81ea245a7993215fb8ff4e1c7f9d */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_dom_import_simplexml, 0, 1, DOMElement, 0)
55
ZEND_ARG_TYPE_INFO(0, node, IS_OBJECT, 0)

0 commit comments

Comments
 (0)