From 24d7fb70d5caf764f339ded30583a703505b8876 Mon Sep 17 00:00:00 2001 From: Cyperghost Date: Wed, 10 Apr 2024 13:07:53 +0200 Subject: [PATCH] Use `$document` as member --- .../files/lib/system/bbcode/DomBBCodeParser.class.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/wcfsetup/install/files/lib/system/bbcode/DomBBCodeParser.class.php b/wcfsetup/install/files/lib/system/bbcode/DomBBCodeParser.class.php index 949a243513..7c4e23d3c6 100644 --- a/wcfsetup/install/files/lib/system/bbcode/DomBBCodeParser.class.php +++ b/wcfsetup/install/files/lib/system/bbcode/DomBBCodeParser.class.php @@ -19,6 +19,7 @@ use wcf\util\StringUtil; final class DomBBCodeParser extends SingletonFactory { protected array $openTagIdentifiers = []; + private \DOMDocument $document; /** * Parses bbcodes in the given DOM document. @@ -26,6 +27,7 @@ final class DomBBCodeParser extends SingletonFactory public function parse(\DOMDocument $document): void { $this->openTagIdentifiers = []; + $this->document = $document; foreach ($document->getElementsByTagName('body')->item(0)->childNodes as $node) { $this->convertBBCodeToMetacodeMarker($node); } @@ -65,7 +67,7 @@ final class DomBBCodeParser extends SingletonFactory // get bbcode tags \preg_match_all($pattern, $node->textContent, $matches); foreach ($matches[0] as $bbcodeTag) { - $metaCodeMarker = $this->createMetacodeMarker($node->ownerDocument, $bbcodeTag); + $metaCodeMarker = $this->createMetacodeMarker($bbcodeTag); if ($metaCodeMarker === null) { continue; } @@ -78,7 +80,7 @@ final class DomBBCodeParser extends SingletonFactory } } - private function createMetacodeMarker(\DOMDocument $document, string $bbcodeTag): ?\DOMElement + private function createMetacodeMarker(string $bbcodeTag): ?\DOMElement { $attributes = []; if (\mb_substr($bbcodeTag, 1, 1) == '/') { @@ -102,7 +104,7 @@ final class DomBBCodeParser extends SingletonFactory return null; } - $metacodeMarker = $document->createElement('woltlab-metacode-marker'); + $metacodeMarker = $this->document->createElement('woltlab-metacode-marker'); $metacodeMarker->setAttribute('data-source', \base64_encode($bbcodeTag)); if ($isClosingTag) { if (empty($this->openTagIdentifiers)) { -- 2.20.1