Skip to content

php-in-php: ext/dom DOMImplementation factory without host DOM (#6140) - #7742

Merged
PurHur merged 1 commit into
masterfrom
agent/runtime-php-dom-6140
Jun 9, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/runtime-php-dom-6140

Conversation

@PurHur

@PurHur PurHur commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add ext/dom/ module with PHP-owned DOM tree state (DomRegistry, VmDom) — no host \DOM* delegation and no new runtime/*.c symbols
  • Implement v1 factory surface: DOMImplementation::createDocumentType, createDocument, hasFeature, and DOMDocument::saveXML + formatOutput property
  • Wire module in lib/Runtime.php; compliance PHPT + unit tests assert Zend parity on the issue repro

php-src reference

  • ext/dom/php_dom.c — dom_implementation_create_document, dom_implementation_create_document_type
  • PHP implementation: ext/dom/VmDom.php, ext/dom/Implementation*.php

C runtime shrink

No C added. lib/AOT/Linker.php unchanged (still only phpc_progress.c thin ABI).

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
vendor/bin/phpunit test/unit/DomModuleTest.php test/compliance/DOMImplementationVMTest.php
php bin/vm.php test/repro-maintainer/dom_implementation_6140.php
'

Output (green):

OK (2 tests, 7 assertions)
OK (1 test, 1 assertion)
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html/>
hasFeature XML 2.0: 1
hasFeature HTML 2.0: 0
hasFeature XBL 2.0: 0

Closes #6140

Made with Cursor

Implement DOMImplementation::createDocument/createDocumentType/hasFeature
and DOMDocument::saveXML in ext/dom/ with PHP-owned node state (DomRegistry).
No new C runtime symbols — only Runtime module load wiring.

Verification: vendor/bin/phpunit test/unit/DomModuleTest.php test/compliance/DOMImplementationVMTest.php
  php bin/vm.php test/repro-maintainer/dom_implementation_6140.php
Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 558d8d3 into master Jun 9, 2026
@PurHur
PurHur deleted the agent/runtime-php-dom-6140 branch June 9, 2026 02:33
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.

php-in-php: DOMImplementation — createDocument/createDocumentType without host DOM (ext/dom/php_dom.c)

1 participant