Skip to content

Regression: SimpleXMLElement::xpath(null) TypeError — Zend Deprecated + Warning + false (ext/simplexml/sxe.c) #31530

Description

@PurHur

Category

Regression: · php-src-strict · SimpleXMLElement::xpath null expression coerce

Problem

SimpleXMLElement::xpath(null) on Zend soft-deprecates null-to-string for $expression, emits Warning: … Invalid expression, and returns false. VM hard-TypeErrors: Argument #1 ($expression) must be of type string (no deprecation, no warning path). Distinct from ctor null gap #31514 and from invalid-expression [] vs false history (#22720).

Probed 2026-08-16 — host Zend PHP 8.2.32 vs php bin/vm.php.

Repro Zend 8.2+ VM (2026-08-16)
$x = new SimpleXMLElement('<a><b/></a>'); $x->xpath(null) Deprecated $expression + Warning Invalid expression + false TypeError: … Argument #1 ($expression) must be of type string

php-src reference

PHP implementation target

  • ext/simplexml/ SimpleXMLElement::xpath — soft-deprecate null→string under php-src-strict, then invalid-expression warning + false
  • Reuse shared string-arg soft-null guards where possible; no new runtime/*.c

Repro

./script/docker-exec.sh -- bash -lc 'php test/repro/maintainer_gap_simplexml_xpath_null.php'
./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_simplexml_xpath_null.php'

Done when

  • xpath(null) emits Zend deprecation + Invalid expression warning and returns false
  • Targeted compliance/PHPUnit guard
  • php-src-strict; no php-compiler-strict shortcut

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 machinebugSomething isn't workingimplementation-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