I want to convert a DOMNode object from a call to getElementsByTagName() to a DOMElement in order to access methods like getElements
DOMNode
getElementsByTagName()
DOMElement
getElements
This is what I use in my project to minimize IDE warning.
/** * Cast a DOMNode into a DOMElement */ function cast_e(DOMNode $node) : DOMElement { if ($node) { if ($node->nodeType === XML_ELEMENT_NODE) { return $node; } } return null; }