Skip to content

Stdlib: DOMImplementation::createDocument() optional args — 2-arg form fatal (ext/dom/php_dom.c) #14408

Closed

Description

@PurHur

Summary

DOMImplementation::createDocument(?string $namespace = null, string $qualifiedName = \"\", ?DOMDocumentType $doctype = null) accepts 0–3 arguments in php-src. VM requires exactly 3 user arguments and throws LogicException: expects exactly 3 arguments for the common 2-arg createDocument(null, 'root') form Zend accepts.

Blocks factory code that creates empty or named-root documents without an explicit doctype.

php-src reference

  • ext/dom/php_dom.c — dom_implementation_create_document
  • ext/dom/dom.stub.php — DOMImplementation::createDocument
  • Current VM: ext/dom/ImplementationCreateDocument.php — arity check count($frame->calledArgs) < 4

PHP implementation target

  • ext/dom/ImplementationCreateDocument.php — default $qualifiedName to '' and $doctype to null when omitted; match Zend arity/TypeError messages

Repro (php-src-strict)

./script/docker-exec.sh -- php test/repro/maintainer_gap_dom_implementation_create_document_optional.php          # Zend: ok
./script/docker-exec.sh -- php bin/vm.php test/repro/maintainer_gap_dom_implementation_create_document_optional.php  # VM: LogicException arity
Call Zend VM (wrong)
createDocument(null, 'root') DOMDocument with <root/> LogicException
createDocument() empty DOMDocument LogicException

Done when

  • 0–3 argument forms match php-src signatures and behavior (php-src-strict)
  • test/repro/maintainer_gap_dom_implementation_create_document_optional.php green on VM
  • PHPUnit guard; VM/JIT/AOT agree when both in scope

Activity

  1. added
    enhancementNew feature or request
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jul 1, 2026
  2. PurHur commented on Jul 2, 2026

    @PurHur
    OwnerAuthor

    claim: cursor-agent-lane-c — batch (issues #14408, #14394)

  3. PurHur commented on Jul 2, 2026

    @PurHur
    OwnerAuthor

    Merged via #15029 — VM repro + dom_implementation_create_document_optional compliance green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions