private function removeComments(HtmlDomParser $dom): HtmlDomParser
    {
        foreach ($dom->find('//comment()') as $commentWrapper) {
            $comment = $commentWrapper->getNode();
            $val = $comment->nodeValue;
            if (\strpos($val, '[') === false) {
                /** @noinspection UnusedFunctionResultInspection */
                $comment->parentNode->removeChild($comment);
            }
        }

        $dom->getDocument()->normalizeDocument();

        return $dom;
    }
private function removeComments(HtmlDomParser $dom): HtmlDomParser
    {
        foreach ($dom->find('//comment()') as $commentWrapper) {
            $comment = $commentWrapper->getNode();
            $val = $comment->nodeValue;
            if (\strpos($val, '[') === false) {
                /** @noinspection UnusedFunctionResultInspection */
                $comment->parentNode->removeChild($comment);
            }
        }

        $dom->getDocument()->normalizeDocument();

        return $dom;
    }
private function removeComments ( HtmlDomParser $ dom ) : HtmlDomParser { foreach ( $ dom -> find ( '//comment()' ) as $ commentWrapper ) { $ comment = $ commentWrapper -> getNode ( ) ; $ val = $ comment -> nodeValue ; if ( \ strpos ( $ val , '[' ) === false ) { /** @noinspection UnusedFunctionResultInspection */ $ comment -> parentNode -> removeChild ( $ comment ) ; } } $ dom -> getDocument ( ) -> normalizeDocument ( ) ; return $ dom ; }
Remove comments in the dom.

@param HtmlDomParser $dom

@return HtmlDomParser
Remove comments in the dom .