1--TEST--
2xml_parser_set_option(): Setting options to invalid values
3--EXTENSIONS--
4xml
5--FILE--
6<?php
7
8$xmlParser = xml_parser_create();
9
10echo "Case folding\n";
11try {
12    xml_parser_set_option($xmlParser, XML_OPTION_CASE_FOLDING, []);
13} catch (ValueError $exception) {
14    echo $exception->getMessage() . "\n";
15}
16try {
17    xml_parser_set_option($xmlParser, XML_OPTION_CASE_FOLDING, new stdClass());
18} catch (TypeError $exception) {
19    echo $exception->getMessage() . "\n";
20}
21
22echo "Skip Whitespace\n";
23try {
24    xml_parser_set_option($xmlParser, XML_OPTION_SKIP_WHITE, []);
25} catch (ValueError $exception) {
26    echo $exception->getMessage() . "\n";
27}
28try {
29    xml_parser_set_option($xmlParser, XML_OPTION_SKIP_WHITE, new stdClass());
30} catch (TypeError $exception) {
31    echo $exception->getMessage() . "\n";
32}
33
34echo "Tag Start\n";
35xml_parser_set_option($xmlParser, XML_OPTION_SKIP_TAGSTART, -5);
36
37xml_parser_set_option($xmlParser, XML_OPTION_SKIP_TAGSTART, []);
38
39xml_parser_set_option($xmlParser, XML_OPTION_SKIP_TAGSTART, new stdClass());
40
41echo "Encodings\n";
42try {
43    xml_parser_set_option($xmlParser, XML_OPTION_TARGET_ENCODING, 'Invalid Encoding');
44} catch (ValueError $exception) {
45    echo $exception->getMessage() . "\n";
46}
47try {
48    xml_parser_set_option($xmlParser, XML_OPTION_TARGET_ENCODING, []);
49} catch (ValueError $exception) {
50    echo $exception->getMessage() . "\n";
51}
52try {
53    xml_parser_set_option($xmlParser, XML_OPTION_TARGET_ENCODING, new stdClass());
54} catch (Error $exception) {
55    echo $exception::class, ': ', $exception->getMessage() . "\n";
56}
57
58?>
59--EXPECTF--
60Case folding
61
62Warning: xml_parser_set_option(): Argument #3 ($value) must be of type string|int|bool, array given in %s on line %d
63
64Warning: xml_parser_set_option(): Argument #3 ($value) must be of type string|int|bool, stdClass given in %s on line %d
65Skip Whitespace
66
67Warning: xml_parser_set_option(): Argument #3 ($value) must be of type string|int|bool, array given in %s on line %d
68
69Warning: xml_parser_set_option(): Argument #3 ($value) must be of type string|int|bool, stdClass given in %s on line %d
70Tag Start
71
72Warning: xml_parser_set_option(): Argument #3 ($value) must be between 0 and 2147483647 for option XML_OPTION_SKIP_TAGSTART in %s on line %d
73
74Warning: xml_parser_set_option(): Argument #3 ($value) must be of type string|int|bool, array given in %s on line %d
75
76Warning: xml_parser_set_option(): Argument #3 ($value) must be of type string|int|bool, stdClass given in %s on line %d
77
78Warning: Object of class stdClass could not be converted to int in %s on line %d
79Encodings
80xml_parser_set_option(): Argument #3 ($value) is not a supported target encoding
81
82Warning: xml_parser_set_option(): Argument #3 ($value) must be of type string|int|bool, array given in %s on line %d
83
84Warning: Array to string conversion in %s on line %d
85xml_parser_set_option(): Argument #3 ($value) is not a supported target encoding
86
87Warning: xml_parser_set_option(): Argument #3 ($value) must be of type string|int|bool, stdClass given in %s on line %d
88Error: Object of class stdClass could not be converted to string
89