diff --git a/src/HtmlProcessor/AbstractHtmlProcessor.php b/src/HtmlProcessor/AbstractHtmlProcessor.php index f4b85f5b..67bdf82e 100644 --- a/src/HtmlProcessor/AbstractHtmlProcessor.php +++ b/src/HtmlProcessor/AbstractHtmlProcessor.php @@ -45,9 +45,9 @@ abstract class AbstractHtmlProcessor = '%][^<]*+(?:<(?!/template>)[^<]*+)*+(?:|$)%i'; /** - * @var \DOMDocument|null + * @var \DOMDocument */ - protected $domDocument = null; + private $domDocument; /** * @var \DOMXPath|null @@ -115,15 +115,13 @@ private function setHtml(string $html): void */ public function getDomDocument(): \DOMDocument { - \assert($this->domDocument instanceof \DOMDocument); - return $this->domDocument; } private function setDomDocument(\DOMDocument $domDocument): void { $this->domDocument = $domDocument; - $this->xPath = new \DOMXPath($this->domDocument); + $this->xPath = new \DOMXPath($domDocument); } /** @@ -219,7 +217,7 @@ private function getBodyElement(): \DOMElement } /** - * Creates a DOM document from the given HTML and stores it in $this->domDocument. + * Creates a DOM document from the given HTML and stores it in `$this->domDocument`. * * The DOM document will always have a BODY element and a document type. */ @@ -230,7 +228,7 @@ private function createUnifiedDomDocument(string $html): void } /** - * Creates a DOMDocument instance from the given HTML and stores it in $this->domDocument. + * Creates a DOMDocument instance from the given HTML and stores it in `$this->domDocument`. */ private function createRawDomDocument(string $html): void { @@ -453,9 +451,7 @@ private function ensurePhpUnrecognizedSelfClosingTagsAreXml(string $html): strin } /** - * Checks that $this->domDocument has a BODY element and adds it if it is missing. - * - * @throws \UnexpectedValueException + * Checks that `$this->domDocument` has a BODY element and adds it if it is missing. */ private function ensureExistenceOfBodyElement(): void {