Bug report
DOMNode::appendChild() returns the appended child which means that if I pass a DOMElement to that method, I can be certain that a DOMElement is returned by it. However, PHPStan does not recognize that and assumes that an instance of any DOMNode subclass can be returned.
Code snippet that reproduces the problem
function appendElement(DOMElement $element, DOMElement $to): DOMElement
{
return $to->appendChild($element);
}
https://phpstan.org/r/4fb72139-58a8-434c-bee8-6cc651dfac65
Expected output
No error.
Did PHPStan help you today? Did it make you happy in any way?
Of course it did!