1--TEST-- 2Error conditions when setting invalid handler callables for xml_set_element_handler() 3--EXTENSIONS-- 4xml 5--FILE-- 6<?php 7declare(strict_types=1); 8 9function dummy() {} 10 11echo 'Invalid $parser:', PHP_EOL; 12$obj = new stdClass(); 13try { 14 xml_set_element_handler($obj, null, null); 15} catch (\Throwable $e) { 16 echo $e::class, ': ', $e->getMessage(), PHP_EOL; 17} 18 19/* Create valid parser */ 20$parser = xml_parser_create(); 21 22echo 'Invalid start callable type true:', PHP_EOL; 23try { 24 xml_set_element_handler($parser, true, null); 25} catch (\Throwable $e) { 26 echo $e::class, ': ', $e->getMessage(), PHP_EOL; 27} 28echo 'Invalid end callable type true:', PHP_EOL; 29try { 30 xml_set_element_handler($parser, null, true); 31} catch (\Throwable $e) { 32 echo $e::class, ': ', $e->getMessage(), PHP_EOL; 33} 34 35echo 'Invalid start callable type int:', PHP_EOL; 36try { 37 xml_set_element_handler($parser, 10, null); 38} catch (\Throwable $e) { 39 echo $e::class, ': ', $e->getMessage(), PHP_EOL; 40} 41echo 'Invalid end callable type int:', PHP_EOL; 42try { 43 xml_set_element_handler($parser, null, 10); 44} catch (\Throwable $e) { 45 echo $e::class, ': ', $e->getMessage(), PHP_EOL; 46} 47 48echo 'Invalid start callable, no object set and string not callable:', PHP_EOL; 49try { 50 xml_set_element_handler($parser, "nonexistent_method", null); 51} catch (\Throwable $e) { 52 echo $e::class, ': ', $e->getMessage(), PHP_EOL; 53} 54echo 'Invalid end callable, no object set and string not callable:', PHP_EOL; 55try { 56 xml_set_element_handler($parser, null, "nonexistent_method"); 57} catch (\Throwable $e) { 58 echo $e::class, ': ', $e->getMessage(), PHP_EOL; 59} 60 61echo 'Invalid start callable, string non existent method on set object:', PHP_EOL; 62xml_set_object($parser, $obj); 63try { 64 xml_set_element_handler($parser, "nonexistent_method", null); 65} catch (\Throwable $e) { 66 echo $e::class, ': ', $e->getMessage(), PHP_EOL; 67} 68echo 'Invalid end callable, string non existent method on set object:', PHP_EOL; 69xml_set_object($parser, $obj); 70try { 71 xml_set_element_handler($parser, null, "nonexistent_method"); 72} catch (\Throwable $e) { 73 echo $e::class, ': ', $e->getMessage(), PHP_EOL; 74} 75 76?> 77--EXPECTF-- 78Invalid $parser: 79TypeError: xml_set_element_handler(): Argument #1 ($parser) must be of type XMLParser, stdClass given 80Invalid start callable type true: 81TypeError: xml_set_element_handler(): Argument #2 ($start_handler) must be of type callable|string|null 82Invalid end callable type true: 83TypeError: xml_set_element_handler(): Argument #3 ($end_handler) must be of type callable|string|null 84Invalid start callable type int: 85TypeError: xml_set_element_handler(): Argument #2 ($start_handler) must be of type callable|string|null 86Invalid end callable type int: 87TypeError: xml_set_element_handler(): Argument #3 ($end_handler) must be of type callable|string|null 88Invalid start callable, no object set and string not callable: 89 90Deprecated: xml_set_element_handler(): Passing non-callable strings is deprecated since 8.4 in %s on line %d 91ValueError: xml_set_element_handler(): Argument #2 ($start_handler) an object must be set via xml_set_object() to be able to lookup method 92Invalid end callable, no object set and string not callable: 93 94Deprecated: xml_set_element_handler(): Passing non-callable strings is deprecated since 8.4 in %s on line %d 95ValueError: xml_set_element_handler(): Argument #3 ($end_handler) an object must be set via xml_set_object() to be able to lookup method 96Invalid start callable, string non existent method on set object: 97 98Deprecated: Function xml_set_object() is deprecated since 8.4, provide a proper method callable to xml_set_*_handler() functions in %s on line %d 99 100Deprecated: xml_set_element_handler(): Passing non-callable strings is deprecated since 8.4 in %s on line %d 101ValueError: xml_set_element_handler(): Argument #2 ($start_handler) method stdClass::nonexistent_method() does not exist 102Invalid end callable, string non existent method on set object: 103 104Deprecated: Function xml_set_object() is deprecated since 8.4, provide a proper method callable to xml_set_*_handler() functions in %s on line %d 105 106Deprecated: xml_set_element_handler(): Passing non-callable strings is deprecated since 8.4 in %s on line %d 107ValueError: xml_set_element_handler(): Argument #3 ($end_handler) method stdClass::nonexistent_method() does not exist 108