mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00

Two issues: - Assumed that at least 1 argument (function name) was provided. - Incorrect error path for the non-callable case. Closes GH-12593.
27 lines
583 B
PHP
27 lines
583 B
PHP
--TEST--
|
|
php:function() edge cases
|
|
--EXTENSIONS--
|
|
dom
|
|
--FILE--
|
|
<?php
|
|
|
|
$doc = new DOMDocument();
|
|
$doc->loadHTML('<a href="https://php.net">hello</a>');
|
|
$xpath = new DOMXpath($doc);
|
|
$xpath->registerNamespace("php", "http://php.net/xpath");
|
|
$xpath->registerPHPFunctions();
|
|
try {
|
|
$xpath->query("//a[php:function(3)]");
|
|
} catch (TypeError $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
try {
|
|
$xpath->query("//a[php:function()]");
|
|
} catch (Throwable $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
|
|
?>
|
|
--EXPECT--
|
|
Handler name must be a string
|
|
Function name must be passed as the first argument
|