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
Category
Regression:· php-src-strict · SimpleXMLElement::xpath null expression coerceProblem
SimpleXMLElement::xpath(null)on Zend soft-deprecates null-to-string for$expression, emitsWarning: … Invalid expression, and returnsfalse. 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[]vsfalsehistory (#22720).Probed 2026-08-16 — host Zend PHP 8.2.32 vs
php bin/vm.php.$x = new SimpleXMLElement('<a><b/></a>'); $x->xpath(null)$expression+ Warning Invalid expression +falseTypeError: … Argument #1 ($expression) must be of type stringphp-src reference
ext/simplexml/sxe.c—xpathstring coerce + libxml evaluate → false + warning on invalidext/simplexml/simplexml.stub.php—xpath(string $expression): array|falsePHP implementation target
ext/simplexml/SimpleXMLElement::xpath— soft-deprecate null→string under php-src-strict, then invalid-expression warning +falseruntime/*.cRepro
Done when
xpath(null)emits Zend deprecation + Invalid expression warning and returnsfalse