psalm
psalm copied to clipboard
SimpleXMLElement passes isset but can still be null
https://psalm.dev/r/199041ce5b
I did not expect this PossiblyNullReference
. If the value is set, then it must be different from null, right?
I found these snippets:
https://psalm.dev/r/199041ce5b
<?php
function foo (SimpleXMLElement $xml): void
{
if (isset($xml['hi'])) {
echo $xml['hi']->count();
}
}
Psalm output (using commit c488d40):
ERROR: PossiblyNullReference - 6:26 - Cannot call method count on possibly null value