Skip to content

Commit

Permalink
Map DOMDocument::class to Gt\Dom\HTMLDocument::class (#449)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
szymanek-event-it authored Nov 30, 2023
1 parent 69935b0 commit 7b62fb3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 7b62fb3

Please sign in to comment.