Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect signature/stub used for XMLWriter::startElementNs #6091

Closed
aboks opened this issue Jul 14, 2021 · 3 comments · Fixed by #6099
Closed

Incorrect signature/stub used for XMLWriter::startElementNs #6091

aboks opened this issue Jul 14, 2021 · 3 comments · Fixed by #6099

Comments

@aboks
Copy link
Contributor

aboks commented Jul 14, 2021

According to the PHP documentation the 1st and 3rd parameters to XMLWriter::startElementNs() accept string|null; see https://www.php.net/manual/en/xmlwriter.startelementns. However, Psalm complains when null is passed as an argument to this method: https://psalm.dev/r/216f3978ac.

Unfortunately I cannot find where Psalm infers these method signatures from; they don't seem to be in the /stubs folder. I would be happy to check and correct the method signatures if I know where to find them.

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/216f3978ac
<?php
$xw = new XMLWriter();
$xw->startElementNs(null, "foo", null);
$xw->endElement();
Psalm output (using commit 09b0167):

ERROR: NullArgument - 3:21 - Argument 1 of XMLWriter::startElementNs cannot be null, null value provided to parameter with type string

ERROR: NullArgument - 3:34 - Argument 3 of XMLWriter::startElementNs cannot be null, null value provided to parameter with type string

@weirdan
Copy link
Collaborator

weirdan commented Jul 14, 2021

@aboks
Copy link
Contributor Author

aboks commented Jul 14, 2021

Thanks! I will try to make a PR with checked/updated XMLWriter stubs somewhere in the next week.

aboks added a commit to aboks/psalm that referenced this issue Jul 15, 2021
Checked and fixed the following, based on the current
documentation in the PHP manual:

* capitalization in method names
* parameter names
* parameter types (especially for nullable params)
* return types (especially for '|false'-types)
* differences between pre- and post-8.0.0-signatures

Fixes vimeo#6091
weirdan pushed a commit to aboks/psalm that referenced this issue Jul 17, 2021
Checked and fixed the following, based on the current
documentation in the PHP manual:

* capitalization in method names
* parameter names
* parameter types (especially for nullable params)
* return types (especially for '|false'-types)
* differences between pre- and post-8.0.0-signatures

Fixes vimeo#6091
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants