1--TEST-- 2DOMXPath::evaluate() with PHP function passing a namespace node-set 3--EXTENSIONS-- 4dom 5--FILE-- 6<?php 7 8$dom = new DOMDocument(); 9$dom->loadXML(<<<XML 10<?xml version="1.0"?> 11<container> 12 <p>hi</p> 13</container> 14XML); 15 16$xpath = new DOMXPath($dom); 17 18function node_test($nodes) { 19 echo "nodes count: ", count($nodes), "\n"; 20 return array_sum(array_map(fn ($node) => strlen($node->nodeName), $nodes)); 21} 22 23$xpath->registerNamespace("php", "http://php.net/xpath"); 24$xpath->registerPhpFunctions(['node_test']); 25var_dump($xpath->evaluate('number(php:function("node_test", //namespace::*))')); 26var_dump($xpath->evaluate('boolean(php:function("node_test", //namespace::*))')); 27 28?> 29--EXPECT-- 30nodes count: 2 31float(18) 32nodes count: 2 33bool(true) 34