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

SimpleXMLELement::addChild return type is incorrect. #10269

Closed
DaveLiddament opened this issue Dec 8, 2023 · 3 comments
Closed

SimpleXMLELement::addChild return type is incorrect. #10269

DaveLiddament opened this issue Dec 8, 2023 · 3 comments
Labels

Comments

@DaveLiddament
Copy link

Bug report

Looking at the PHP docs SimpleXMLElement::addChild can return null, however PHPStan is reporting that addChild can never return null

Code snippet that reproduces the problem

https://phpstan.org/r/8b9cd1df-ed7c-48e0-916a-d8e127e50257

Expected output

I'd expect no issues reported in the code snippet.

Is the fix as simple as updating this line in functionMap?

- 'SimpleXMLElement::addChild' => ['static', 'name'=>'string', 'value='=>'string|null', 'ns='=>'string|null'],
+ 'SimpleXMLElement::addChild' => ['static|null', 'name'=>'string', 'value='=>'string|null', 'ns='=>'string|null'],

Did PHPStan help you today? Did it make you happy in any way?

PHPStan helps me every day. And I've also got to speak at a few conferences off the back of your tool!

@phpstan-bot
Copy link
Contributor

@DaveLiddament After the latest push in 1.11.x, PHPStan now reports different result with your code snippet:

@@ @@
-6: Strict comparison using !== between SimpleXMLElement and null will always evaluate to true.
+No errors

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src#2808

Copy link

github-actions bot commented Jan 9, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants