1--TEST-- 2Swap underlying object to call methods with xml_set_object() new object has missing methods 3--EXTENSIONS-- 4xml 5--FILE-- 6<?php 7 8class A { 9 public function start_element($parser, $name, $attributes) { 10 global $b; 11 echo "A::start_element($name)\n"; 12 try { 13 xml_set_object($parser, $b); 14 } catch (\Throwable $e) { 15 echo $e::class, ': ', $e->getMessage(), PHP_EOL; 16 exit(); 17 } 18 } 19 public function end_element($parser, $name) { 20 echo "B::end_element($name)\n"; 21 } 22} 23 24class B { 25 public function start_element($parser, $name) { 26 echo "B::start_element($name)\n"; 27 } 28} 29 30$a = new A; 31$b = new B; 32 33$parser = xml_parser_create(); 34xml_set_object($parser, $a); 35xml_set_element_handler($parser, "start_element", "end_element"); 36xml_parse($parser, <<<XML 37<?xml version="1.0"?> 38<container> 39 <child/> 40</container> 41XML); 42 43?> 44--EXPECTF-- 45Deprecated: Function xml_set_object() is deprecated since 8.4, provide a proper method callable to xml_set_*_handler() functions in %s on line %d 46 47Deprecated: xml_set_element_handler(): Passing non-callable strings is deprecated since 8.4 in %s on line %d 48A::start_element(CONTAINER) 49 50Deprecated: Function xml_set_object() is deprecated since 8.4, provide a proper method callable to xml_set_*_handler() functions in %s on line %d 51ValueError: xml_set_object(): Argument #2 ($object) cannot safely swap to object of class B as method "end_element" does not exist, which was set via xml_set_element_handler() 52