-
Notifications
You must be signed in to change notification settings - Fork 666
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
Bug: DOMText::nodeValue can be null #7479
Comments
I found these snippets: https://psalm.dev/r/a1bfbfe662<?php
$a = new \DOMText();
if (is_string($a->nodeValue)) {
//
}
|
Thanks for reporting! Care for a PR? |
It seems it might be caused by this line. psalm/dictionaries/PropertyMap.php Line 373 in f6a8921
On the DOMNode the property is nullable (so the PropertyMap should be changed), but the docs do mention this:
Which could be interpreted as meaning that on DOMElement's, the nodeValue property will always return a string. As the textContent is not nullable. Edit: I can't really find any code in the source code indicating different behavior of the property on the DOMElement though. But i am not sure how to figure out if that statement on the docs is correct or not. |
I'm guessing it's this. On the other hand, this says that can be nullable as well, so there would have to be some other guarantee that content is always available. I'm guessing it's never null for an xmlElement, but I'm not 100% sure. Looks like it could be null due to memory allocation failure. That might be ok to ignore, if it fails to allocate that there's a really high chance PHP is going to crash extremely soon anyway. |
Mhm, looking at this code it seems they opted to return an empty string, rather than return null if they can't get the content? |
That's for Given that that check exists for |
…odevalue-can-be-null BugFix: Made DOMNode::nodeValue nullable
Should be fixed by #7501 |
This is related to #1965
is_string($domText->nodeValue)
results in:https://psalm.dev/r/a1bfbfe662
But https://www.php.net/manual/class.domtext.php says:
The text was updated successfully, but these errors were encountered: