Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Map DOMDocument::class to Gt\Dom\HTMLDocument::class#449

Merged
g105b merged 2 commits intophpgt:masterfrom
szymanek-event-it:hotfix/class-map-document
Nov 30, 2023
Merged

Map DOMDocument::class to Gt\Dom\HTMLDocument::class#449
g105b merged 2 commits intophpgt:masterfrom
szymanek-event-it:hotfix/class-map-document

Conversation

@szymanek-event-it
Copy link
Contributor

Fixes DOMDocument::registerNodeClass(): Argument #2 ($extendedClass) must not be an abstract class from change in PHP 8.1.26

Fixes `DOMDocument::registerNodeClass(): Argument #2 ($extendedClass) must not be an abstract class` from change in PHP 8.1.26
@g105b
Copy link
Member

g105b commented Nov 29, 2023

Hi @szymanek-event-it , thanks for your contribution.

I think this PR is correct, but the thing that I'm not sure about is how it works with XMLDocument types? Would this have any side effects when working with this subclass of document?

Ensures DOMDocument is always mapped to the class that extends abstract Gt\Dom\Document
@szymanek-event-it
Copy link
Contributor Author

Hello @g105b, the DOMDocument could never have been initialized with the mapping to Gt\Dom\Document. This would have meant creating an instance of the abstract class Gt\Dom\Document. However, I changed the mapping to use static::class which points to the class extending Gt\Dom\Document to make this possible in the future.

@g105b
Copy link
Member

g105b commented Nov 29, 2023

I see, thank you. I will give it a few test runs with some real-world applications I use the DOM heavily in and will get it merged by the end of the week 👍

@szymanek-event-it
Copy link
Contributor Author

szymanek-event-it commented Nov 29, 2023

Please create a release afterwards. The Lib currently crashes, because the php developers changed the DOMDocument::registerNodeClass() method to throw an error, if the name of an abstract class is passed into it.

@g105b
Copy link
Member

g105b commented Nov 29, 2023

Will do!

@g105b
Copy link
Member

g105b commented Nov 29, 2023

I've just checked a few projects and it all looks fine, but I've noticed that this bug was caused by updating PHP (both 8.1 and 8.2 are affected). It's a strange update to php-src, but I'm all for more type safety. I'll merge this in as soon as I can.

@g105b
Copy link
Member

g105b commented Nov 30, 2023

Works really well, thank you for your contribution. I'll include this into a minor patch release now.

@g105b g105b merged commit 7b62fb3 into phpgt:master Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants