1--TEST-- 2registerPhpFunctions() with callables - error cases 3--EXTENSIONS-- 4xsl 5--FILE-- 6<?php 7 8require __DIR__ . '/xpath_callables.inc'; 9 10$proc = createProcessor([]); 11try { 12 $proc->registerPhpFunctions("nonexistent"); 13} catch (TypeError $e) { 14 echo $e->getMessage(), "\n"; 15} 16 17try { 18 $proc->registerPhpFunctions(function () {}); 19} catch (TypeError $e) { 20 echo $e->getMessage(), "\n"; 21} 22 23try { 24 $proc->registerPhpFunctions([function () {}]); 25} catch (Throwable $e) { 26 echo $e->getMessage(), "\n"; 27} 28 29try { 30 $proc->registerPhpFunctions([var_dump(...)]); 31} catch (Throwable $e) { 32 echo $e->getMessage(), "\n"; 33} 34 35try { 36 $proc->registerPhpFunctions(["nonexistent"]); 37} catch (Throwable $e) { 38 echo $e->getMessage(), "\n"; 39} 40 41try { 42 $proc->registerPhpFunctions(["" => var_dump(...)]); 43} catch (Throwable $e) { 44 echo $e->getMessage(), "\n"; 45} 46 47try { 48 $proc->registerPhpFunctions(["\0" => var_dump(...)]); 49} catch (Throwable $e) { 50 echo $e->getMessage(), "\n"; 51} 52 53try { 54 $proc->registerPhpFunctions(""); 55} catch (Throwable $e) { 56 echo $e->getMessage(), "\n"; 57} 58 59?> 60--EXPECT-- 61XSLTProcessor::registerPHPFunctions(): Argument #1 ($functions) must be a callable, function "nonexistent" not found or invalid function name 62XSLTProcessor::registerPHPFunctions(): Argument #1 ($functions) must be of type array|string|null, Closure given 63Object of class Closure could not be converted to string 64Object of class Closure could not be converted to string 65XSLTProcessor::registerPHPFunctions(): Argument #1 ($functions) must be an array with valid callbacks as values, function "nonexistent" not found or invalid function name 66XSLTProcessor::registerPHPFunctions(): Argument #1 ($functions) must be an array containing valid callback names 67XSLTProcessor::registerPHPFunctions(): Argument #1 ($functions) must be an array containing valid callback names 68XSLTProcessor::registerPHPFunctions(): Argument #1 ($functions) must be a valid callback name 69