From b5acd316c6de06c86995ed097b7394c67218f7d1 Mon Sep 17 00:00:00 2001 From: divinity76 Date: Mon, 29 May 2023 16:53:00 +0200 Subject: [PATCH] DOMNodeList::item may return DOMElement. 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"); because DOMNode does not have getAttribute (while DOMElement does). documenting the DOMElement return type should fix Intelephense's linter. --- ext/dom/php_dom.stub.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/dom/php_dom.stub.php b/ext/dom/php_dom.stub.php index f26518c0ba8ec..45b54c21d6c2c 100644 --- a/ext/dom/php_dom.stub.php +++ b/ext/dom/php_dom.stub.php @@ -232,7 +232,7 @@ public function count(): int {} public function getIterator(): Iterator {} - /** @return DOMNode|DOMNameSpaceNode|null */ + /** @return DOMElement|DOMNode|DOMNameSpaceNode|null */ public function item(int $index) {} }