summaryrefslogtreecommitdiff
path: root/ext/xmlreader/php_xmlreader.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2021-03-01 09:54:24 +0100
committerNikita Popov <nikita.ppv@gmail.com>2021-03-01 09:54:24 +0100
commit1ec7cc96dcba3cd5e243d3c5ac98b9ef0779be38 (patch)
treee9cc547a6c8298cc4f9978cb25f14388bd9a1a8f /ext/xmlreader/php_xmlreader.c
parent6f38a53940f02891ce8367ddf66b4a344765211f (diff)
downloadphp-git-1ec7cc96dcba3cd5e243d3c5ac98b9ef0779be38.tar.gz
Clarify types in XmlReader property handling
Make it clearer that the specified type is really the only type that can be returned.
Diffstat (limited to 'ext/xmlreader/php_xmlreader.c')
-rw-r--r--ext/xmlreader/php_xmlreader.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/ext/xmlreader/php_xmlreader.c b/ext/xmlreader/php_xmlreader.c
index c264993405..b12f53dc77 100644
--- a/ext/xmlreader/php_xmlreader.c
+++ b/ext/xmlreader/php_xmlreader.c
@@ -85,7 +85,7 @@ static int xmlreader_property_reader(xmlreader_object *obj, xmlreader_prop_handl
if (hnd->read_int_func) {
retint = hnd->read_int_func(obj->ptr);
if (retint == -1) {
- php_error_docref(NULL, E_WARNING, "Internal libxml error returned");
+ zend_throw_error(NULL, "Failed to read property due to libxml error");
return FAILURE;
}
}
@@ -100,15 +100,13 @@ static int xmlreader_property_reader(xmlreader_object *obj, xmlreader_prop_handl
ZVAL_EMPTY_STRING(rv);
}
break;
- /* this IS_FALSE actually means it's a BOOL type */
- case IS_FALSE:
+ case _IS_BOOL:
ZVAL_BOOL(rv, retint);
break;
case IS_LONG:
ZVAL_LONG(rv, retint);
break;
- default:
- ZVAL_NULL(rv);
+ EMPTY_SWITCH_DEFAULT_CASE()
}
return SUCCESS;
@@ -1169,10 +1167,10 @@ PHP_MINIT_FUNCTION(xmlreader)
xmlreader_register_prop_handler(&xmlreader_prop_handlers, "attributeCount", xmlTextReaderAttributeCount, NULL, IS_LONG);
xmlreader_register_prop_handler(&xmlreader_prop_handlers, "baseURI", NULL, xmlTextReaderConstBaseUri, IS_STRING);
xmlreader_register_prop_handler(&xmlreader_prop_handlers, "depth", xmlTextReaderDepth, NULL, IS_LONG);
- xmlreader_register_prop_handler(&xmlreader_prop_handlers, "hasAttributes", xmlTextReaderHasAttributes, NULL, IS_FALSE);
- xmlreader_register_prop_handler(&xmlreader_prop_handlers, "hasValue", xmlTextReaderHasValue, NULL, IS_FALSE);
- xmlreader_register_prop_handler(&xmlreader_prop_handlers, "isDefault", xmlTextReaderIsDefault, NULL, IS_FALSE);
- xmlreader_register_prop_handler(&xmlreader_prop_handlers, "isEmptyElement", xmlTextReaderIsEmptyElement, NULL, IS_FALSE);
+ xmlreader_register_prop_handler(&xmlreader_prop_handlers, "hasAttributes", xmlTextReaderHasAttributes, NULL, _IS_BOOL);
+ xmlreader_register_prop_handler(&xmlreader_prop_handlers, "hasValue", xmlTextReaderHasValue, NULL, _IS_BOOL);
+ xmlreader_register_prop_handler(&xmlreader_prop_handlers, "isDefault", xmlTextReaderIsDefault, NULL, _IS_BOOL);
+ xmlreader_register_prop_handler(&xmlreader_prop_handlers, "isEmptyElement", xmlTextReaderIsEmptyElement, NULL, _IS_BOOL);
xmlreader_register_prop_handler(&xmlreader_prop_handlers, "localName", NULL, xmlTextReaderConstLocalName, IS_STRING);
xmlreader_register_prop_handler(&xmlreader_prop_handlers, "name", NULL, xmlTextReaderConstName, IS_STRING);
xmlreader_register_prop_handler(&xmlreader_prop_handlers, "namespaceURI", NULL, xmlTextReaderConstNamespaceUri, IS_STRING);