From 7b62fb3a8bf508d0fa8a204d563d936c78524fd9 Mon Sep 17 00:00:00 2001 From: szymanek-event-it <56961594+szymanek-event-it@users.noreply.github.com> Date: Thu, 30 Nov 2023 10:06:07 +0100 Subject: [PATCH] Map DOMDocument::class to Gt\Dom\HTMLDocument::class (#449) * Map DOMDocument::class to Gt\Dom\HTMLDocument::class Fixes `DOMDocument::registerNodeClass(): Argument #2 ($extendedClass) must not be an abstract class` from change in PHP 8.1.26 * Map DOMDocument::class to static::class Ensures DOMDocument is always mapped to the class that extends abstract Gt\Dom\Document --- src/Document.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Document.php b/src/Document.php index 919e631a..6beefc8d 100644 --- a/src/Document.php +++ b/src/Document.php @@ -36,7 +36,7 @@ abstract class Document extends DOMDocument implements Stringable, StreamInterfa use RegisteredNodeClass; const NODE_CLASS_LOOKUP = [ - DOMDocument::class => Document::class, + DOMDocument::class => self::class, DOMAttr::class => Attr::class, DOMCdataSection::class => CdataSection::class, DOMCharacterData::class => CharacterData::class, @@ -357,6 +357,9 @@ public function writeln($line):int { private function registerNodeClasses():void { foreach(self::NODE_CLASS_LOOKUP as $nativeClass => $gtClass) { + if ($gtClass === self::class) { + $gtClass = static::class; + } $this->registerNodeClass($nativeClass, $gtClass); } }