Skip to content

DOM-Modernisierung: \Dom\HTMLDocument (PHP 8.4) statt libxml-Workarounds#419

Closed
Copilot wants to merge 3 commits into
mainfrom
copilot/update-html-parser-implementation
Closed

DOM-Modernisierung: \Dom\HTMLDocument (PHP 8.4) statt libxml-Workarounds#419
Copilot wants to merge 3 commits into
mainfrom
copilot/update-html-parser-implementation

Conversation

Copilot AI commented May 10, 2026

Copy link
Copy Markdown

Replaces all legacy DOMDocument + @loadHTML() patterns with PHP 8.4's native \Dom\HTMLDocument and \Dom\XMLDocument APIs, eliminating error-suppression hacks, the deprecated utf8_decode() call, and global libxml_use_internal_errors() side-effects.

PHP version

  • package.yml: php: '>=8.0'php: '>=8.4'

MFormParser.php

  • use DOMDocument / DOMElement / DOMNodeListuse Dom\HTMLDocument
  • All DOM instantiation patterns replaced:
// Before
$dom = new DOMDocument('1.0', 'utf-8');
@$dom->loadHTML('<?xml encoding="utf-8" ?>' . $html);

// After
$dom = HTMLDocument::createFromString($html, LIBXML_NOERROR);
  • utf8_decode($html) removed from all loadHTML call-sites
  • getBodyInner() rewritten — drops C14N + regex body extraction in favour of $dom->body?->innerHTML / $element->outerHTML
  • Method signatures updated: DOMDocument → HTMLDocument, DOMElement → \Dom\Element, DOMNodeList<DOMElement> → \Dom\HTMLCollection
  • instanceof DOMElementinstanceof \Dom\Element

HtmlToSvgConverter.php

  • Unused $this->dom property removed (was @phpstan-ignore property.onlyWritten)
  • libxml_use_internal_errors(true) removed from constructor
  • $this->svg migrated from DOMDocument to Dom\XMLDocument::createEmpty('1.0', 'UTF-8')
  • saveXML()saveXml() (PHP 8.4 naming)
  • Type hints: \DOMElement / \DOMNode\Dom\Element / \Dom\Node

Copilot AI and others added 2 commits May 10, 2026 08:52
Copilot AI changed the title [WIP] Refactor HTML parser to use \Dom\HTMLDocument in PHP 8.4 DOM-Modernisierung: \Dom\HTMLDocument (PHP 8.4) statt libxml-Workarounds May 10, 2026
Copilot AI requested a review from skerbis May 10, 2026 08:54
@skerbis skerbis closed this May 13, 2026
@skerbis skerbis deleted the copilot/update-html-parser-implementation branch May 22, 2026 21:34
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.

[9.2] DOM-Modernisierung: \Dom\HTMLDocument (PHP 8.4) statt libxml-Workarounds

2 participants