Skip to content

Commit 1ec7cc9

Browse files
committed
Clarify types in XmlReader property handling
Make it clearer that the specified type is really the only type that can be returned.
1 parent 6f38a53 commit 1ec7cc9

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

ext/xmlreader/php_xmlreader.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ static int xmlreader_property_reader(xmlreader_object *obj, xmlreader_prop_handl
8585
if (hnd->read_int_func) {
8686
retint = hnd->read_int_func(obj->ptr);
8787
if (retint == -1) {
88-
php_error_docref(NULL, E_WARNING, "Internal libxml error returned");
88+
zend_throw_error(NULL, "Failed to read property due to libxml error");
8989
return FAILURE;
9090
}
9191
}
@@ -100,15 +100,13 @@ static int xmlreader_property_reader(xmlreader_object *obj, xmlreader_prop_handl
100100
ZVAL_EMPTY_STRING(rv);
101101
}
102102
break;
103-
/* this IS_FALSE actually means it's a BOOL type */
104-
case IS_FALSE:
103+
case _IS_BOOL:
105104
ZVAL_BOOL(rv, retint);
106105
break;
107106
case IS_LONG:
108107
ZVAL_LONG(rv, retint);
109108
break;
110-
default:
111-
ZVAL_NULL(rv);
109+
EMPTY_SWITCH_DEFAULT_CASE()
112110
}
113111

114112
return SUCCESS;
@@ -1169,10 +1167,10 @@ PHP_MINIT_FUNCTION(xmlreader)
11691167
xmlreader_register_prop_handler(&xmlreader_prop_handlers, "attributeCount", xmlTextReaderAttributeCount, NULL, IS_LONG);
11701168
xmlreader_register_prop_handler(&xmlreader_prop_handlers, "baseURI", NULL, xmlTextReaderConstBaseUri, IS_STRING);
11711169
xmlreader_register_prop_handler(&xmlreader_prop_handlers, "depth", xmlTextReaderDepth, NULL, IS_LONG);
1172-
xmlreader_register_prop_handler(&xmlreader_prop_handlers, "hasAttributes", xmlTextReaderHasAttributes, NULL, IS_FALSE);
1173-
xmlreader_register_prop_handler(&xmlreader_prop_handlers, "hasValue", xmlTextReaderHasValue, NULL, IS_FALSE);
1174-
xmlreader_register_prop_handler(&xmlreader_prop_handlers, "isDefault", xmlTextReaderIsDefault, NULL, IS_FALSE);
1175-
xmlreader_register_prop_handler(&xmlreader_prop_handlers, "isEmptyElement", xmlTextReaderIsEmptyElement, NULL, IS_FALSE);
1170+
xmlreader_register_prop_handler(&xmlreader_prop_handlers, "hasAttributes", xmlTextReaderHasAttributes, NULL, _IS_BOOL);
1171+
xmlreader_register_prop_handler(&xmlreader_prop_handlers, "hasValue", xmlTextReaderHasValue, NULL, _IS_BOOL);
1172+
xmlreader_register_prop_handler(&xmlreader_prop_handlers, "isDefault", xmlTextReaderIsDefault, NULL, _IS_BOOL);
1173+
xmlreader_register_prop_handler(&xmlreader_prop_handlers, "isEmptyElement", xmlTextReaderIsEmptyElement, NULL, _IS_BOOL);
11761174
xmlreader_register_prop_handler(&xmlreader_prop_handlers, "localName", NULL, xmlTextReaderConstLocalName, IS_STRING);
11771175
xmlreader_register_prop_handler(&xmlreader_prop_handlers, "name", NULL, xmlTextReaderConstName, IS_STRING);
11781176
xmlreader_register_prop_handler(&xmlreader_prop_handlers, "namespaceURI", NULL, xmlTextReaderConstNamespaceUri, IS_STRING);

0 commit comments

Comments
 (0)