1--TEST--
2Swap underlying object to call methods with xml_set_object()
3--EXTENSIONS--
4xml
5--FILE--
6<?php
7
8function end_handler(XMLParser $parser, string $tag) {
9    echo "end_handler($tag)\n";
10}
11
12class A {
13    public function start_element($parser, $name, $attributes) {
14        global $b;
15        xml_set_object($parser, $b);
16        echo "A::start_element($name)\n";
17    }
18    public function PIHandler($parser, $target, $data) {
19        echo "A::PIHandler($target)\n";
20    }
21}
22
23class B {
24    public function start_element($parser, $name) {
25        echo "B::start_element($name)\n";
26    }
27    public function end_element($parser, $name) {
28        echo "B::end_element($name)\n";
29    }
30    public function PIHandler($parser, $target, $data) {
31        echo "B::PIHandler($target)\n";
32    }
33}
34
35$a = new A;
36$b = new B;
37
38$parser = xml_parser_create();
39xml_set_object($parser, $a);
40xml_set_element_handler($parser, "start_element", "end_handler");
41xml_set_processing_instruction_handler($parser, [$a, "PIHandler"]);
42xml_parse($parser, <<<XML
43<?xml version="1.0"?>
44<container>
45    <child/>
46</container>
47<?pi-test data ?>
48XML);
49
50?>
51--EXPECTF--
52Deprecated: Function xml_set_object() is deprecated since 8.4, provide a proper method callable to xml_set_*_handler() functions in %s on line %d
53
54Deprecated: xml_set_element_handler(): Passing non-callable strings is deprecated since 8.4 in %s on line %d
55
56Deprecated: Function xml_set_object() is deprecated since 8.4, provide a proper method callable to xml_set_*_handler() functions in %s on line %d
57A::start_element(CONTAINER)
58B::start_element(CHILD)
59end_handler(CHILD)
60end_handler(CONTAINER)
61A::PIHandler(pi-test)
62