Category
php-in-php | stdlib
Problem
DOMImplementation is the factory for empty DOM trees (createDocument, createDocumentType, hasFeature). It is required for XML generation without parsing input and is referenced by php-types stubs. This compiler has no DOM surface (#3326 tracks DOMDocument generally); class_exists('DOMImplementation') is false (Jun 2026 audit).
Implementing DOMImplementation first establishes the document factory path that DOMDocument / DOMElement build on.
php-src reference
ext/dom/php_dom.c — dom_domimplementation_class_entry, dom_implementation_create_document
ext/dom/php_dom.stub.php — DOMImplementation::createDocument, createDocumentType, hasFeature
ext/dom/dom_ce.h — class registration
Repro (failure today)
<?php
$impl = new DOMImplementation();
$doctype = $impl->createDocumentType('html', '-//W3C//DTD HTML 4.01//EN', 'http://www.w3.org/TR/html4/strict.dtd');
$doc = $impl->createDocument(null, 'html', $doctype);
$doc->formatOutput = true;
echo $doc->saveXML();
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php repro.php'
php repro.php
| Runtime |
Output |
| Zend PHP 8.x (dom) |
XML string with <!DOCTYPE html> + <html> |
bin/vm.php |
fatal — class DOMImplementation not found |
Scope (this repo)
| Area |
Path |
Notes |
| Module |
ext/dom/ (new) |
PHP class handlers for DOMImplementation, DOMDocumentType, DOMDocument (minimal) |
| PHP-in-PHP |
Tree nodes in ext/dom/ + VM object handlers |
Do not grow runtime/*.c; thin libxml ABI only if unavoidable |
| libxml |
host libxml2 for v1 acceptable |
Pairs with #6058 error buffer migration |
| Tests |
test/compliance/cases/dom/implementation_create_document.phpt |
|
| JIT/AOT |
VM-first v1 |
|
v1: createDocument, createDocumentType, hasFeature('XML','2.0'). Defer: XPath (#6066), import bridges (#6057).
Done when
Verification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter DOMImplementation'
Links
Category
php-in-php|stdlibProblem
DOMImplementationis the factory for empty DOM trees (createDocument,createDocumentType,hasFeature). It is required for XML generation without parsing input and is referenced by php-types stubs. This compiler has no DOM surface (#3326 tracksDOMDocumentgenerally);class_exists('DOMImplementation')is false (Jun 2026 audit).Implementing
DOMImplementationfirst establishes the document factory path thatDOMDocument/DOMElementbuild on.php-src reference
ext/dom/php_dom.c—dom_domimplementation_class_entry,dom_implementation_create_documentext/dom/php_dom.stub.php—DOMImplementation::createDocument,createDocumentType,hasFeatureext/dom/dom_ce.h— class registrationRepro (failure today)
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php repro.php' php repro.php<!DOCTYPE html>+<html>bin/vm.phpDOMImplementationnot foundScope (this repo)
ext/dom/(new)DOMImplementation,DOMDocumentType,DOMDocument(minimal)ext/dom/+ VM object handlersruntime/*.c; thin libxml ABI only if unavoidablelibxml2for v1 acceptabletest/compliance/cases/dom/implementation_create_document.phptv1:
createDocument,createDocumentType,hasFeature('XML','2.0'). Defer: XPath (#6066), import bridges (#6057).Done when
hasFeaturereturns expected booleans for XML/HTML featuresclass_exists('DOMImplementation')true; registered as internal class./script/ci-fast.sh --filter DOMImplementationgreenlib/AOT/runtime/*.c(PHP path only)Verification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter DOMImplementation'Links