Skip to content

Stdlib: Dom\XPath missing — namespaced XPath after Dom\HTMLDocument/XMLDocument (ext/dom/php_dom.stub.php) #20757

Description

@PurHur

Category

stdlib · php-src-strict · Dom living XPath · pillar 4 (DOM)

Problem

PHP 8.4 Dom\XPath is the living-standard equivalent of DOMXPath for Dom\HTMLDocument / Dom\XMLDocument. On PHP_COMPILER_PROFILE=8.4 the class is absent (Class "Dom\XPath" not found) while legacy DOMXPath already accepts living documents.

Repro Zend 8.4+ (ext/dom) VM PROFILE=8.4 (2026-07-19)
class_exists('Dom\\XPath') true false
new Dom\\XPath($htmlDoc) Dom\XPath fatal Class not found
$xp->query('//p')->item(0) on HTMLDocument node N/A

php-src reference

PHP implementation target

  • Register Dom\XPath (+ Dom\NodeList for query/evaluate node-set returns) in ext/dom/DomLivingBuiltinClasses.php
  • Living construct accepting Dom\Document (reject legacy DOMDocument with TypeError)
  • Reuse VmDomXPath handlers; return Dom\NodeList for living XPath (keep DOMNodeList for legacy)
  • PHP-in-PHP; no new runtime/*.c

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && PHP_COMPILER_PROFILE=8.4 php bin/vm.php test/repro/maintainer_gap_dom_xpath_living.php'

Done when

  • class_exists('Dom\\XPath') true on PROFILE=8.4
  • new Dom\\XPath(Dom\\HTMLDocument|XMLDocument) works; query/evaluate/registerNamespace/quote green
  • Node-set results are Dom\\NodeList (not legacy DOMNodeList)
  • Compliance .phpt under test/compliance/cases/dom/ or stdlib/
  • php-src-strict; no php-compiler-strict shortcut

No activity

Activity on this issue will appear here.

Activity

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