Skip to content

Conversation

@divinity76
Copy link
Contributor

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.

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.
Copy link
Member

@ndossche ndossche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that when changing stub files you should also update the arginfo C file by running build/gen_stub.php, and add that file (in this case only the hash changes though so it isn't a big deal). You don't have to change it now in this case, I can do it during the merge as I'll have to do it anyway when merging upwards.

Patch looks good to me. I'll wait until CI finishes. Thanks for you contribution.

@ndossche
Copy link
Member

CI complains about the generated arginfo files, like I already hinted at. Other than that looks good, I'll merge this.

@ndossche ndossche closed this in 761b9a4 May 29, 2023
kocsismate added a commit to php/doc-en that referenced this pull request Oct 28, 2023
DOMElement was missing until php/php-src#11342 fixed the return type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants