Skip to content

Commit 74629e0

Browse files
committed
Stop special casing false value type
1 parent d8f0eec commit 74629e0

File tree

3 files changed

+11
-35
lines changed

3 files changed

+11
-35
lines changed

ext/xml/tests/set_handler_errors.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ try {
5252
Invalid $parser:
5353
TypeError: xml_set_processing_instruction_handler(): Argument #1 ($parser) must be of type XMLParser, stdClass given
5454
Invalid callable type true:
55-
TypeError: xml_set_processing_instruction_handler(): Argument #2 ($handler) must be of type callable|string|null|false
55+
TypeError: xml_set_processing_instruction_handler(): Argument #2 ($handler) must be of type callable|string|null
5656
Invalid callable type int:
57-
TypeError: xml_set_processing_instruction_handler(): Argument #2 ($handler) must be of type callable|string|null|false
57+
TypeError: xml_set_processing_instruction_handler(): Argument #2 ($handler) must be of type callable|string|null
5858
String not callable and no object set:
5959
ValueError: xml_set_processing_instruction_handler(): Argument #2 ($handler) an object must be set via xml_set_object() to be able to lookup method
6060
String non existent method on set object:

ext/xml/tests/xml_set_element_handler_errors.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ try {
7878
Invalid $parser:
7979
TypeError: xml_set_element_handler(): Argument #1 ($parser) must be of type XMLParser, stdClass given
8080
Invalid start callable type true:
81-
TypeError: xml_set_element_handler(): Argument #2 ($start_handler) must be of type callable|string|null|false
81+
TypeError: xml_set_element_handler(): Argument #2 ($start_handler) must be of type callable|string|null
8282
Invalid end callable type true:
83-
TypeError: xml_set_element_handler(): Argument #3 ($end_handler) must be of type callable|string|null|false
83+
TypeError: xml_set_element_handler(): Argument #3 ($end_handler) must be of type callable|string|null
8484
Invalid start callable type int:
85-
TypeError: xml_set_element_handler(): Argument #2 ($start_handler) must be of type callable|string|null|false
85+
TypeError: xml_set_element_handler(): Argument #2 ($start_handler) must be of type callable|string|null
8686
Invalid end callable type int:
87-
TypeError: xml_set_element_handler(): Argument #3 ($end_handler) must be of type callable|string|null|false
87+
TypeError: xml_set_element_handler(): Argument #3 ($end_handler) must be of type callable|string|null
8888
Invalid start callable, no object set and string not callable:
8989
ValueError: xml_set_element_handler(): Argument #2 ($start_handler) an object must be set via xml_set_object() to be able to lookup method
9090
Invalid end callable, no object set and string not callable:

ext/xml/xml.c

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,27 +1175,15 @@ PHP_FUNCTION(xml_set_element_handler)
11751175
RETURN_THROWS();
11761176
} else {
11771177
switch (Z_TYPE_P(dummy_start)) {
1178-
case IS_FALSE:
11791178
case IS_NULL:
1180-
break;
11811179
case IS_STRING:
1182-
// TODO ... how to deal with callable on one arg and false on another?
1183-
default:
1184-
zend_argument_type_error(2, "must be of type callable|string|null|false");
1185-
RETURN_THROWS();
1186-
}
1187-
switch (Z_TYPE_P(dummy_end)) {
1188-
case IS_FALSE:
1189-
case IS_NULL:
11901180
break;
1191-
case IS_STRING:
1192-
// TODO ... how to deal with callable on one arg and false on another?
11931181
default:
1194-
zend_argument_type_error(3, "must be of type callable|string|null|false");
1182+
zend_argument_type_error(2, "must be of type callable|string|null");
11951183
RETURN_THROWS();
11961184
}
1197-
1198-
parser = Z_XMLPARSER_P(pind);
1185+
zend_argument_type_error(3, "must be of type callable|string|null");
1186+
RETURN_THROWS();
11991187
}
12001188
}
12011189

@@ -1234,11 +1222,6 @@ static void php_xml_set_handler_parse_callable(
12341222
xml_parser *local_parser;
12351223
*parser = local_parser = Z_XMLPARSER_P(pind);
12361224

1237-
if (ZSTR_LEN(method_name) == 0) {
1238-
/* Free handler, so just return and a uninitialized FCC communicates this */
1239-
return;
1240-
}
1241-
12421225
bool status = php_xml_check_string_method_arg(2, local_parser, method_name, parser_handler_fcc);
12431226
if (status == false) {
12441227
RETURN_FALSE;
@@ -1248,15 +1231,8 @@ static void php_xml_set_handler_parse_callable(
12481231
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Oz", &pind, xml_parser_ce, &dummy) == FAILURE) {
12491232
RETURN_THROWS();
12501233
}
1251-
switch (Z_TYPE_P(dummy)) {
1252-
case IS_FALSE:
1253-
break;
1254-
default:
1255-
zend_argument_type_error(2, "must be of type callable|string|null|false");
1256-
RETURN_THROWS();
1257-
}
1258-
1259-
*parser = Z_XMLPARSER_P(pind);
1234+
zend_argument_type_error(2, "must be of type callable|string|null");
1235+
RETURN_THROWS();
12601236
}
12611237
}
12621238

0 commit comments

Comments
 (0)