summaryrefslogtreecommitdiff
path: root/ext/dom
diff options
context:
space:
mode:
Diffstat (limited to 'ext/dom')
-rw-r--r--ext/dom/attr.c8
-rw-r--r--ext/dom/characterdata.c6
-rw-r--r--ext/dom/document.c22
-rw-r--r--ext/dom/documenttype.c12
-rw-r--r--ext/dom/dom_iterators.c2
-rw-r--r--ext/dom/element.c10
-rw-r--r--ext/dom/entity.c6
-rw-r--r--ext/dom/node.c46
-rw-r--r--ext/dom/notation.c4
-rw-r--r--ext/dom/parentnode.c6
-rw-r--r--ext/dom/php_dom.c126
-rw-r--r--ext/dom/php_dom.h5
-rw-r--r--ext/dom/php_dom.stub.php4
-rw-r--r--ext/dom/php_dom_arginfo.h235
-rw-r--r--ext/dom/processinginstruction.c6
-rw-r--r--ext/dom/tests/DOMCharacterData_data_error_002.phpt10
-rw-r--r--ext/dom/tests/DOMCharacterData_length_error_001.phpt10
-rw-r--r--ext/dom/tests/DOMDocumentType_entities_error_001.phpt10
-rw-r--r--ext/dom/tests/DOMDocumentType_internalSubset_error_001.phpt10
-rw-r--r--ext/dom/tests/DOMDocumentType_name_error_001.phpt10
-rw-r--r--ext/dom/tests/DOMDocumentType_notations_error_001.phpt10
-rw-r--r--ext/dom/tests/DOMDocumentType_publicId_error_001.phpt10
-rw-r--r--ext/dom/tests/DOMDocumentType_systemId_error_001.phpt10
-rw-r--r--ext/dom/tests/DOMDocument_saveHTMLFile_invalid_filename.phpt2
-rw-r--r--ext/dom/tests/dom003.phpt4
-rw-r--r--ext/dom/tests/dom_set_attr_node.phpt4
-rw-r--r--ext/dom/text.c2
-rw-r--r--ext/dom/xml_common.h2
-rw-r--r--ext/dom/xpath.c4
29 files changed, 428 insertions, 168 deletions
diff --git a/ext/dom/attr.c b/ext/dom/attr.c
index e348f8fc5a..383f390951 100644
--- a/ext/dom/attr.c
+++ b/ext/dom/attr.c
@@ -81,7 +81,7 @@ int dom_attr_name_read(dom_object *obj, zval *retval)
attrp = (xmlAttrPtr) dom_object_get_node(obj);
if (attrp == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -117,7 +117,7 @@ int dom_attr_value_read(dom_object *obj, zval *retval)
xmlChar *content;
if (attrp == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -138,7 +138,7 @@ int dom_attr_value_write(dom_object *obj, zval *newval)
xmlAttrPtr attrp = (xmlAttrPtr) dom_object_get_node(obj);
if (attrp == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -171,7 +171,7 @@ int dom_attr_owner_element_read(dom_object *obj, zval *retval)
nodep = dom_object_get_node(obj);
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
diff --git a/ext/dom/characterdata.c b/ext/dom/characterdata.c
index cd332c8db4..fa8f3dfc71 100644
--- a/ext/dom/characterdata.c
+++ b/ext/dom/characterdata.c
@@ -41,7 +41,7 @@ int dom_characterdata_data_read(dom_object *obj, zval *retval)
xmlChar *content;
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -61,7 +61,7 @@ int dom_characterdata_data_write(dom_object *obj, zval *newval)
zend_string *str;
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -90,7 +90,7 @@ int dom_characterdata_length_read(dom_object *obj, zval *retval)
long length = 0;
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
diff --git a/ext/dom/document.c b/ext/dom/document.c
index dbbabb8bff..fd6563803e 100644
--- a/ext/dom/document.c
+++ b/ext/dom/document.c
@@ -55,7 +55,7 @@ int dom_document_doctype_read(dom_object *obj, zval *retval)
xmlDtdPtr dtdptr;
if (docp == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -95,7 +95,7 @@ int dom_document_document_element_read(dom_object *obj, zval *retval)
xmlNode *root;
if (docp == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -121,7 +121,7 @@ int dom_document_encoding_read(dom_object *obj, zval *retval)
char *encoding;
if (docp == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -143,7 +143,7 @@ zend_result dom_document_encoding_write(dom_object *obj, zval *newval)
xmlCharEncodingHandlerPtr handler;
if (docp == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -183,7 +183,7 @@ int dom_document_standalone_read(dom_object *obj, zval *retval)
docp = (xmlDocPtr) dom_object_get_node(obj);
if (docp == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -197,7 +197,7 @@ int dom_document_standalone_write(dom_object *obj, zval *newval)
zend_long standalone;
if (docp == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -220,7 +220,7 @@ int dom_document_version_read(dom_object *obj, zval *retval)
char *version;
if (docp == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -241,7 +241,7 @@ int dom_document_version_write(dom_object *obj, zval *newval)
zend_string *str;
if (docp == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -452,7 +452,7 @@ int dom_document_document_uri_read(dom_object *obj, zval *retval)
char *url;
if (docp == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -472,7 +472,7 @@ int dom_document_document_uri_write(dom_object *obj, zval *newval)
zend_string *str;
if (docp == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -795,7 +795,7 @@ PHP_METHOD(DOMDocument, importNode)
xmlNodePtr nodep, retnodep;
dom_object *intern, *nodeobj;
int ret;
- zend_bool recursive = 0;
+ bool recursive = 0;
/* See http://www.xmlsoft.org/html/libxml-tree.html#xmlDocCopyNode for meaning of values */
int extended_recursive;
diff --git a/ext/dom/documenttype.c b/ext/dom/documenttype.c
index e910cf4009..0046ac7f45 100644
--- a/ext/dom/documenttype.c
+++ b/ext/dom/documenttype.c
@@ -33,7 +33,7 @@ int dom_documenttype_name_read(dom_object *obj, zval *retval)
xmlDtdPtr dtdptr = (xmlDtdPtr) dom_object_get_node(obj);
if (dtdptr == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -56,7 +56,7 @@ int dom_documenttype_entities_read(dom_object *obj, zval *retval)
dom_object *intern;
if (doctypep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -84,7 +84,7 @@ int dom_documenttype_notations_read(dom_object *obj, zval *retval)
dom_object *intern;
if (doctypep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -110,7 +110,7 @@ int dom_documenttype_public_id_read(dom_object *obj, zval *retval)
xmlDtdPtr dtdptr = (xmlDtdPtr) dom_object_get_node(obj);
if (dtdptr == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -135,7 +135,7 @@ int dom_documenttype_system_id_read(dom_object *obj, zval *retval)
xmlDtdPtr dtdptr = (xmlDtdPtr) dom_object_get_node(obj);
if (dtdptr == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -160,7 +160,7 @@ int dom_documenttype_internal_subset_read(dom_object *obj, zval *retval)
xmlDtdPtr intsubset;
if (dtdptr == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
diff --git a/ext/dom/dom_iterators.c b/ext/dom/dom_iterators.c
index f56d249034..c3fbb356e4 100644
--- a/ext/dom/dom_iterators.c
+++ b/ext/dom/dom_iterators.c
@@ -182,7 +182,7 @@ static void php_dom_iterator_move_forward(zend_object_iterator *iter) /* {{{ */
int previndex=0;
HashTable *nodeht;
zval *entry;
- zend_bool do_curobj_undef = 1;
+ bool do_curobj_undef = 1;
php_dom_iterator *iterator = (php_dom_iterator *)iter;
diff --git a/ext/dom/element.c b/ext/dom/element.c
index 450d694c41..1d93aa3371 100644
--- a/ext/dom/element.c
+++ b/ext/dom/element.c
@@ -117,7 +117,7 @@ int dom_element_tag_name_read(dom_object *obj, zval *retval)
nodep = dom_object_get_node(obj);
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -1014,7 +1014,7 @@ PHP_METHOD(DOMElement, hasAttributeNS)
}
/* }}} end dom_element_has_attribute_ns */
-static void php_set_attribute_id(xmlAttrPtr attrp, zend_bool is_id) /* {{{ */
+static void php_set_attribute_id(xmlAttrPtr attrp, bool is_id) /* {{{ */
{
if (is_id == 1 && attrp->atype != XML_ATTRIBUTE_ID) {
xmlChar *id_val;
@@ -1044,7 +1044,7 @@ PHP_METHOD(DOMElement, setIdAttribute)
dom_object *intern;
char *name;
size_t name_len;
- zend_bool is_id;
+ bool is_id;
id = ZEND_THIS;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sb", &name, &name_len, &is_id) == FAILURE) {
@@ -1080,7 +1080,7 @@ PHP_METHOD(DOMElement, setIdAttributeNS)
dom_object *intern;
size_t uri_len, name_len;
char *uri, *name;
- zend_bool is_id;
+ bool is_id;
id = ZEND_THIS;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ssb", &uri, &uri_len, &name, &name_len, &is_id) == FAILURE) {
@@ -1114,7 +1114,7 @@ PHP_METHOD(DOMElement, setIdAttributeNode)
xmlNode *nodep;
xmlAttrPtr attrp;
dom_object *intern, *attrobj;
- zend_bool is_id;
+ bool is_id;
id = ZEND_THIS;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ob", &node, dom_attr_class_entry, &is_id) == FAILURE) {
diff --git a/ext/dom/entity.c b/ext/dom/entity.c
index 7ad43a1ee3..53f2b20bd1 100644
--- a/ext/dom/entity.c
+++ b/ext/dom/entity.c
@@ -41,7 +41,7 @@ int dom_entity_public_id_read(dom_object *obj, zval *retval)
xmlEntity *nodep = (xmlEntity *) dom_object_get_node(obj);
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -66,7 +66,7 @@ int dom_entity_system_id_read(dom_object *obj, zval *retval)
xmlEntity *nodep = (xmlEntity *) dom_object_get_node(obj);
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -92,7 +92,7 @@ int dom_entity_notation_name_read(dom_object *obj, zval *retval)
char *content;
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
diff --git a/ext/dom/node.c b/ext/dom/node.c
index a6f88b5c0f..253073598c 100644
--- a/ext/dom/node.c
+++ b/ext/dom/node.c
@@ -45,7 +45,7 @@ int dom_node_node_name_read(dom_object *obj, zval *retval)
nodep = dom_object_get_node(obj);
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -127,7 +127,7 @@ int dom_node_node_value_read(dom_object *obj, zval *retval)
char *str = NULL;
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -166,7 +166,7 @@ int dom_node_node_value_write(dom_object *obj, zval *newval)
zend_string *str;
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -212,7 +212,7 @@ int dom_node_node_type_read(dom_object *obj, zval *retval)
nodep = dom_object_get_node(obj);
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -240,7 +240,7 @@ int dom_node_parent_node_read(dom_object *obj, zval *retval)
nodep = dom_object_get_node(obj);
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -267,7 +267,7 @@ int dom_node_child_nodes_read(dom_object *obj, zval *retval)
dom_object *intern;
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -291,7 +291,7 @@ int dom_node_first_child_read(dom_object *obj, zval *retval)
nodep = dom_object_get_node(obj);
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -322,7 +322,7 @@ int dom_node_last_child_read(dom_object *obj, zval *retval)
nodep = dom_object_get_node(obj);
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -353,7 +353,7 @@ int dom_node_previous_sibling_read(dom_object *obj, zval *retval)
nodep = dom_object_get_node(obj);
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -381,7 +381,7 @@ int dom_node_next_sibling_read(dom_object *obj, zval *retval)
nodep = dom_object_get_node(obj);
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -409,7 +409,7 @@ int dom_node_previous_element_sibling_read(dom_object *obj, zval *retval)
nodep = dom_object_get_node(obj);
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -442,7 +442,7 @@ int dom_node_next_element_sibling_read(dom_object *obj, zval *retval)
nodep = dom_object_get_node(obj);
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -474,7 +474,7 @@ int dom_node_attributes_read(dom_object *obj, zval *retval)
dom_object *intern;
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -502,7 +502,7 @@ int dom_node_owner_document_read(dom_object *obj, zval *retval)
xmlDocPtr docp;
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -533,7 +533,7 @@ int dom_node_namespace_uri_read(dom_object *obj, zval *retval)
char *str = NULL;
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -573,7 +573,7 @@ int dom_node_prefix_read(dom_object *obj, zval *retval)
char *str = NULL;
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -611,7 +611,7 @@ int dom_node_prefix_write(dom_object *obj, zval *newval)
nodep = dom_object_get_node(obj);
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -682,7 +682,7 @@ int dom_node_local_name_read(dom_object *obj, zval *retval)
xmlNode *nodep = dom_object_get_node(obj);
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -708,7 +708,7 @@ int dom_node_base_uri_read(dom_object *obj, zval *retval)
xmlChar *baseuri;
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -736,7 +736,7 @@ int dom_node_text_content_read(dom_object *obj, zval *retval)
char *str = NULL;
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -758,7 +758,7 @@ int dom_node_text_content_write(dom_object *obj, zval *newval)
zend_string *str;
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -1271,7 +1271,7 @@ PHP_METHOD(DOMNode, cloneNode)
xmlNode *n, *node;
int ret;
dom_object *intern;
- zend_bool recursive = 0;
+ bool recursive = 0;
id = ZEND_THIS;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &recursive) == FAILURE) {
@@ -1543,7 +1543,7 @@ static void dom_canonicalization(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{
xmlDocPtr docp;
xmlNodeSetPtr nodeset = NULL;
dom_object *intern;
- zend_bool exclusive=0, with_comments=0;
+ bool exclusive=0, with_comments=0;
xmlChar **inclusive_ns_prefixes = NULL;
char *file = NULL;
int ret = -1;
diff --git a/ext/dom/notation.c b/ext/dom/notation.c
index f1e0c1ba38..15148d9a6f 100644
--- a/ext/dom/notation.c
+++ b/ext/dom/notation.c
@@ -42,7 +42,7 @@ int dom_notation_public_id_read(dom_object *obj, zval *retval)
xmlEntityPtr nodep = (xmlEntityPtr) dom_object_get_node(obj);
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -67,7 +67,7 @@ int dom_notation_system_id_read(dom_object *obj, zval *retval)
xmlEntityPtr nodep = (xmlEntityPtr) dom_object_get_node(obj);
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
diff --git a/ext/dom/parentnode.c b/ext/dom/parentnode.c
index 375c692dca..25f79595a3 100644
--- a/ext/dom/parentnode.c
+++ b/ext/dom/parentnode.c
@@ -35,7 +35,7 @@ int dom_parent_node_first_element_child_read(dom_object *obj, zval *retval)
nodep = dom_object_get_node(obj);
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -68,7 +68,7 @@ int dom_parent_node_last_element_child_read(dom_object *obj, zval *retval)
nodep = dom_object_get_node(obj);
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -102,7 +102,7 @@ int dom_parent_node_child_element_count(dom_object *obj, zval *retval)
nodep = dom_object_get_node(obj);
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c
index 351c138622..618b2fe7d0 100644
--- a/ext/dom/php_dom.c
+++ b/ext/dom/php_dom.c
@@ -559,8 +559,6 @@ void dom_xpath_objects_free_storage(zend_object *object);
/* {{{ PHP_MINIT_FUNCTION(dom) */
PHP_MINIT_FUNCTION(dom)
{
- zend_class_entry ce;
-
memcpy(&dom_object_handlers, &std_object_handlers, sizeof(zend_object_handlers));
dom_object_handlers.offset = XtOffsetOf(dom_object, std);
dom_object_handlers.free_obj = dom_objects_free_storage;
@@ -579,20 +577,17 @@ PHP_MINIT_FUNCTION(dom)
zend_hash_init(&classes, 0, NULL, NULL, 1);
- INIT_CLASS_ENTRY(ce, "DOMException", class_DOMException_methods);
- dom_domexception_class_entry = zend_register_internal_class_ex(&ce, zend_ce_exception);
- dom_domexception_class_entry->ce_flags |= ZEND_ACC_FINAL;
- zend_declare_property_long(dom_domexception_class_entry, "code", sizeof("code")-1, 0, ZEND_ACC_PUBLIC);
+ dom_domexception_class_entry = register_class_DOMException(zend_ce_exception);
- INIT_CLASS_ENTRY(ce, "DOMParentNode", class_DOMParentNode_methods);
- dom_parentnode_class_entry = zend_register_internal_interface(&ce);
+ dom_parentnode_class_entry = register_class_DOMParentNode();
- INIT_CLASS_ENTRY(ce, "DOMChildNode", class_DOMChildNode_methods);
- dom_childnode_class_entry = zend_register_internal_interface(&ce);
+ dom_childnode_class_entry = register_class_DOMChildNode();
- REGISTER_DOM_CLASS(ce, "DOMImplementation", NULL, class_DOMImplementation_methods, dom_domimplementation_class_entry);
+ dom_domimplementation_class_entry = register_class_DOMImplementation();
+ dom_domimplementation_class_entry->create_object = dom_objects_new;
- REGISTER_DOM_CLASS(ce, "DOMNode", NULL, class_DOMNode_methods, dom_node_class_entry);
+ dom_node_class_entry = register_class_DOMNode();
+ dom_node_class_entry->create_object = dom_objects_new;
zend_hash_init(&dom_node_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
dom_register_prop_handler(&dom_node_prop_handlers, "nodeName", sizeof("nodeName")-1, dom_node_node_name_read, NULL);
@@ -611,9 +606,10 @@ PHP_MINIT_FUNCTION(dom)
dom_register_prop_handler(&dom_node_prop_handlers, "localName", sizeof("localName")-1, dom_node_local_name_read, NULL);
dom_register_prop_handler(&dom_node_prop_handlers, "baseURI", sizeof("baseURI")-1, dom_node_base_uri_read, NULL);
dom_register_prop_handler(&dom_node_prop_handlers, "textContent", sizeof("textContent")-1, dom_node_text_content_read, dom_node_text_content_write);
- zend_hash_add_ptr(&classes, ce.name, &dom_node_prop_handlers);
+ zend_hash_add_ptr(&classes, dom_node_class_entry->name, &dom_node_prop_handlers);
- REGISTER_DOM_CLASS(ce, "DOMNameSpaceNode", NULL, NULL, dom_namespace_node_class_entry);
+ dom_namespace_node_class_entry = register_class_DOMNameSpaceNode();
+ dom_namespace_node_class_entry->create_object = dom_objects_new;
zend_hash_init(&dom_namespace_node_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
dom_register_prop_handler(&dom_namespace_node_prop_handlers, "nodeName", sizeof("nodeName")-1, dom_node_node_name_read, NULL);
@@ -624,9 +620,10 @@ PHP_MINIT_FUNCTION(dom)
dom_register_prop_handler(&dom_namespace_node_prop_handlers, "namespaceURI", sizeof("namespaceURI")-1, dom_node_namespace_uri_read, NULL);
dom_register_prop_handler(&dom_namespace_node_prop_handlers, "ownerDocument", sizeof("ownerDocument")-1, dom_node_owner_document_read, NULL);
dom_register_prop_handler(&dom_namespace_node_prop_handlers, "parentNode", sizeof("parentNode")-1, dom_node_parent_node_read, NULL);
- zend_hash_add_ptr(&classes, ce.name, &dom_namespace_node_prop_handlers);
+ zend_hash_add_ptr(&classes, dom_namespace_node_class_entry->name, &dom_namespace_node_prop_handlers);
- REGISTER_DOM_CLASS(ce, "DOMDocumentFragment", dom_node_class_entry, class_DOMDocumentFragment_methods, dom_documentfragment_class_entry);
+ dom_documentfragment_class_entry = register_class_DOMDocumentFragment(dom_node_class_entry, dom_parentnode_class_entry);
+ dom_documentfragment_class_entry->create_object = dom_objects_new;
zend_hash_init(&dom_documentfragment_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
dom_register_prop_handler(&dom_documentfragment_prop_handlers, "firstElementChild", sizeof("firstElementChild")-1, dom_parent_node_first_element_child_read, NULL);
@@ -634,10 +631,10 @@ PHP_MINIT_FUNCTION(dom)
dom_register_prop_handler(&dom_documentfragment_prop_handlers, "childElementCount", sizeof("childElementCount")-1, dom_parent_node_child_element_count, NULL);
zend_hash_merge(&dom_documentfragment_prop_handlers, &dom_node_prop_handlers, dom_copy_prop_handler, 0);
- zend_hash_add_ptr(&classes, ce.name, &dom_documentfragment_prop_handlers);
- zend_class_implements(dom_documentfragment_class_entry, 1, dom_parentnode_class_entry);
+ zend_hash_add_ptr(&classes, dom_documentfragment_class_entry->name, &dom_documentfragment_prop_handlers);
- REGISTER_DOM_CLASS(ce, "DOMDocument", dom_node_class_entry, class_DOMDocument_methods, dom_document_class_entry);
+ dom_document_class_entry = register_class_DOMDocument(dom_node_class_entry, dom_parentnode_class_entry);
+ dom_document_class_entry->create_object = dom_objects_new;
zend_hash_init(&dom_document_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
dom_register_prop_handler(&dom_document_prop_handlers, "doctype", sizeof("doctype")-1, dom_document_doctype_read, NULL);
dom_register_prop_handler(&dom_document_prop_handlers, "implementation", sizeof("implementation")-1, dom_document_implementation_read, NULL);
@@ -664,30 +661,26 @@ PHP_MINIT_FUNCTION(dom)
dom_register_prop_handler(&dom_document_prop_handlers, "childElementCount", sizeof("childElementCount")-1, dom_parent_node_child_element_count, NULL);
zend_hash_merge(&dom_document_prop_handlers, &dom_node_prop_handlers, dom_copy_prop_handler, 0);
- zend_hash_add_ptr(&classes, ce.name, &dom_document_prop_handlers);
- zend_class_implements(dom_document_class_entry, 1, dom_parentnode_class_entry);
+ zend_hash_add_ptr(&classes, dom_document_class_entry->name, &dom_document_prop_handlers);
- INIT_CLASS_ENTRY(ce, "DOMNodeList", class_DOMNodeList_methods);
- ce.create_object = dom_nnodemap_objects_new;
- dom_nodelist_class_entry = zend_register_internal_class_ex(&ce, NULL);
+ dom_nodelist_class_entry = register_class_DOMNodeList(zend_ce_aggregate, zend_ce_countable);
+ dom_nodelist_class_entry->create_object = dom_nnodemap_objects_new;
dom_nodelist_class_entry->get_iterator = php_dom_get_iterator;
- zend_class_implements(dom_nodelist_class_entry, 2, zend_ce_aggregate, zend_ce_countable);
zend_hash_init(&dom_nodelist_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
dom_register_prop_handler(&dom_nodelist_prop_handlers, "length", sizeof("length")-1, dom_nodelist_length_read, NULL);
- zend_hash_add_ptr(&classes, ce.name, &dom_nodelist_prop_handlers);
+ zend_hash_add_ptr(&classes, dom_nodelist_class_entry->name, &dom_nodelist_prop_handlers);
- INIT_CLASS_ENTRY(ce, "DOMNamedNodeMap", class_DOMNamedNodeMap_methods);
- ce.create_object = dom_nnodemap_objects_new;
- dom_namednodemap_class_entry = zend_register_internal_class_ex(&ce, NULL);
+ dom_namednodemap_class_entry = register_class_DOMNamedNodeMap(zend_ce_aggregate, zend_ce_countable);
+ dom_namednodemap_class_entry->create_object = dom_nnodemap_objects_new;
dom_namednodemap_class_entry->get_iterator = php_dom_get_iterator;
- zend_class_implements(dom_namednodemap_class_entry, 2, zend_ce_aggregate, zend_ce_countable);
zend_hash_init(&dom_namednodemap_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
dom_register_prop_handler(&dom_namednodemap_prop_handlers, "length", sizeof("length")-1, dom_namednodemap_length_read, NULL);
- zend_hash_add_ptr(&classes, ce.name, &dom_namednodemap_prop_handlers);
+ zend_hash_add_ptr(&classes, dom_namednodemap_class_entry->name, &dom_namednodemap_prop_handlers);
- REGISTER_DOM_CLASS(ce, "DOMCharacterData", dom_node_class_entry, class_DOMCharacterData_methods, dom_characterdata_class_entry);
+ dom_characterdata_class_entry = register_class_DOMCharacterData(dom_node_class_entry, dom_childnode_class_entry);
+ dom_characterdata_class_entry->create_object = dom_objects_new;
zend_hash_init(&dom_characterdata_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
dom_register_prop_handler(&dom_characterdata_prop_handlers, "data", sizeof("data")-1, dom_characterdata_data_read, dom_characterdata_data_write);
@@ -695,11 +688,10 @@ PHP_MINIT_FUNCTION(dom)
dom_register_prop_handler(&dom_characterdata_prop_handlers, "previousElementSibling", sizeof("previousElementSibling")-1, dom_node_previous_element_sibling_read, NULL);
dom_register_prop_handler(&dom_characterdata_prop_handlers, "nextElementSibling", sizeof("nextElementSibling")-1, dom_node_next_element_sibling_read, NULL);
zend_hash_merge(&dom_characterdata_prop_handlers, &dom_node_prop_handlers, dom_copy_prop_handler, 0);
- zend_hash_add_ptr(&classes, ce.name, &dom_characterdata_prop_handlers);
-
- zend_class_implements(dom_characterdata_class_entry, 1, dom_childnode_class_entry);
+ zend_hash_add_ptr(&classes, dom_characterdata_class_entry->name, &dom_characterdata_prop_handlers);
- REGISTER_DOM_CLASS(ce, "DOMAttr", dom_node_class_entry, class_DOMAttr_methods, dom_attr_class_entry);
+ dom_attr_class_entry = register_class_DOMAttr(dom_node_class_entry);
+ dom_attr_class_entry->create_object = dom_objects_new;
zend_hash_init(&dom_attr_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
dom_register_prop_handler(&dom_attr_prop_handlers, "name", sizeof("name")-1, dom_attr_name_read, NULL);
@@ -708,9 +700,10 @@ PHP_MINIT_FUNCTION(dom)
dom_register_prop_handler(&dom_attr_prop_handlers, "ownerElement", sizeof("ownerElement")-1, dom_attr_owner_element_read, NULL);
dom_register_prop_handler(&dom_attr_prop_handlers, "schemaTypeInfo", sizeof("schemaTypeInfo")-1, dom_attr_schema_type_info_read, NULL);
zend_hash_merge(&dom_attr_prop_handlers, &dom_node_prop_handlers, dom_copy_prop_handler, 0);
- zend_hash_add_ptr(&classes, ce.name, &dom_attr_prop_handlers);
+ zend_hash_add_ptr(&classes, dom_attr_class_entry->name, &dom_attr_prop_handlers);
- REGISTER_DOM_CLASS(ce, "DOMElement", dom_node_class_entry, class_DOMElement_methods, dom_element_class_entry);
+ dom_element_class_entry = register_class_DOMElement(dom_node_class_entry, dom_parentnode_class_entry, dom_childnode_class_entry);
+ dom_element_class_entry->create_object = dom_objects_new;
zend_hash_init(&dom_element_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
dom_register_prop_handler(&dom_element_prop_handlers, "tagName", sizeof("tagName")-1, dom_element_tag_name_read, NULL);
@@ -721,24 +714,26 @@ PHP_MINIT_FUNCTION(dom)
dom_register_prop_handler(&dom_element_prop_handlers, "previousElementSibling", sizeof("previousElementSibling")-1, dom_node_previous_element_sibling_read, NULL);
dom_register_prop_handler(&dom_element_prop_handlers, "nextElementSibling", sizeof("nextElementSibling")-1, dom_node_next_element_sibling_read, NULL);
zend_hash_merge(&dom_element_prop_handlers, &dom_node_prop_handlers, dom_copy_prop_handler, 0);
- zend_hash_add_ptr(&classes, ce.name, &dom_element_prop_handlers);
-
- zend_class_implements(dom_element_class_entry, 2, dom_parentnode_class_entry, dom_childnode_class_entry);
+ zend_hash_add_ptr(&classes, dom_element_class_entry->name, &dom_element_prop_handlers);
- REGISTER_DOM_CLASS(ce, "DOMText", dom_characterdata_class_entry, class_DOMText_methods, dom_text_class_entry);
+ dom_text_class_entry = register_class_DOMText(dom_characterdata_class_entry);
+ dom_text_class_entry->create_object = dom_objects_new;
zend_hash_init(&dom_text_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
dom_register_prop_handler(&dom_text_prop_handlers, "wholeText", sizeof("wholeText")-1, dom_text_whole_text_read, NULL);
zend_hash_merge(&dom_text_prop_handlers, &dom_characterdata_prop_handlers, dom_copy_prop_handler, 0);
- zend_hash_add_ptr(&classes, ce.name, &dom_text_prop_handlers);
+ zend_hash_add_ptr(&classes, dom_text_class_entry->name, &dom_text_prop_handlers);
- REGISTER_DOM_CLASS(ce, "DOMComment", dom_characterdata_class_entry, class_DOMComment_methods, dom_comment_class_entry);
- zend_hash_add_ptr(&classes, ce.name, &dom_characterdata_prop_handlers);
+ dom_comment_class_entry = register_class_DOMComment(dom_characterdata_class_entry);
+ dom_comment_class_entry->create_object = dom_objects_new;
+ zend_hash_add_ptr(&classes, dom_comment_class_entry->name, &dom_characterdata_prop_handlers);
- REGISTER_DOM_CLASS(ce, "DOMCdataSection", dom_text_class_entry, class_DOMCdataSection_methods, dom_cdatasection_class_entry);
- zend_hash_add_ptr(&classes, ce.name, &dom_text_prop_handlers);
+ dom_cdatasection_class_entry = register_class_DOMCdataSection(dom_text_class_entry);
+ dom_cdatasection_class_entry->create_object = dom_objects_new;
+ zend_hash_add_ptr(&classes, dom_cdatasection_class_entry->name, &dom_text_prop_handlers);
- REGISTER_DOM_CLASS(ce, "DOMDocumentType", dom_node_class_entry, class_DOMDocumentType_methods, dom_documenttype_class_entry);
+ dom_documenttype_class_entry = register_class_DOMDocumentType(dom_node_class_entry);
+ dom_documenttype_class_entry->create_object = dom_objects_new;
zend_hash_init(&dom_documenttype_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
dom_register_prop_handler(&dom_documenttype_prop_handlers, "name", sizeof("name")-1, dom_documenttype_name_read, NULL);
@@ -748,17 +743,19 @@ PHP_MINIT_FUNCTION(dom)
dom_register_prop_handler(&dom_documenttype_prop_handlers, "systemId", sizeof("systemId")-1, dom_documenttype_system_id_read, NULL);
dom_register_prop_handler(&dom_documenttype_prop_handlers, "internalSubset", sizeof("internalSubset")-1, dom_documenttype_internal_subset_read, NULL);
zend_hash_merge(&dom_documenttype_prop_handlers, &dom_node_prop_handlers, dom_copy_prop_handler, 0);
- zend_hash_add_ptr(&classes, ce.name, &dom_documenttype_prop_handlers);
+ zend_hash_add_ptr(&classes, dom_documenttype_class_entry->name, &dom_documenttype_prop_handlers);
- REGISTER_DOM_CLASS(ce, "DOMNotation", dom_node_class_entry, class_DOMNotation_methods, dom_notation_class_entry);
+ dom_notation_class_entry = register_class_DOMNotation(dom_node_class_entry);
+ dom_notation_class_entry->create_object = dom_objects_new;
zend_hash_init(&dom_notation_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
dom_register_prop_handler(&dom_notation_prop_handlers, "publicId", sizeof("publicId")-1, dom_notation_public_id_read, NULL);
dom_register_prop_handler(&dom_notation_prop_handlers, "systemId", sizeof("systemId")-1, dom_notation_system_id_read, NULL);
zend_hash_merge(&dom_notation_prop_handlers, &dom_node_prop_handlers, dom_copy_prop_handler, 0);
- zend_hash_add_ptr(&classes, ce.name, &dom_notation_prop_handlers);
+ zend_hash_add_ptr(&classes, dom_notation_class_entry->name, &dom_notation_prop_handlers);
- REGISTER_DOM_CLASS(ce, "DOMEntity", dom_node_class_entry, class_DOMEntity_methods, dom_entity_class_entry);
+ dom_entity_class_entry = register_class_DOMEntity(dom_node_class_entry);
+ dom_entity_class_entry->create_object = dom_objects_new;
zend_hash_init(&dom_entity_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
dom_register_prop_handler(&dom_entity_prop_handlers, "publicId", sizeof("publicId")-1, dom_entity_public_id_read, NULL);
@@ -768,32 +765,33 @@ PHP_MINIT_FUNCTION(dom)
dom_register_prop_handler(&dom_entity_prop_handlers, "encoding", sizeof("encoding")-1, dom_entity_encoding_read, dom_entity_encoding_write);
dom_register_prop_handler(&dom_entity_prop_handlers, "version", sizeof("version")-1, dom_entity_version_read, dom_entity_version_write);
zend_hash_merge(&dom_entity_prop_handlers, &dom_node_prop_handlers, dom_copy_prop_handler, 0);
- zend_hash_add_ptr(&classes, ce.name, &dom_entity_prop_handlers);
+ zend_hash_add_ptr(&classes, dom_entity_class_entry->name, &dom_entity_prop_handlers);
- REGISTER_DOM_CLASS(ce, "DOMEntityReference", dom_node_class_entry, class_DOMEntityReference_methods, dom_entityreference_class_entry);
- zend_hash_add_ptr(&classes, ce.name, &dom_node_prop_handlers);
+ dom_entityreference_class_entry = register_class_DOMEntityReference(dom_node_class_entry);
+ dom_entityreference_class_entry->create_object = dom_objects_new;
+ zend_hash_add_ptr(&classes, dom_entityreference_class_entry->name, &dom_node_prop_handlers);
- REGISTER_DOM_CLASS(ce, "DOMProcessingInstruction", dom_node_class_entry, class_DOMProcessingInstruction_methods, dom_processinginstruction_class_entry);
+ dom_processinginstruction_class_entry = register_class_DOMProcessingInstruction(dom_node_class_entry);
+ dom_processinginstruction_class_entry->create_object = dom_objects_new;
zend_hash_init(&dom_processinginstruction_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
dom_register_prop_handler(&dom_processinginstruction_prop_handlers, "target", sizeof("target")-1, dom_processinginstruction_target_read, NULL);
dom_register_prop_handler(&dom_processinginstruction_prop_handlers, "data", sizeof("data")-1, dom_processinginstruction_data_read, dom_processinginstruction_data_write);
zend_hash_merge(&dom_processinginstruction_prop_handlers, &dom_node_prop_handlers, dom_copy_prop_handler, 0);
- zend_hash_add_ptr(&classes, ce.name, &dom_processinginstruction_prop_handlers);
+ zend_hash_add_ptr(&classes, dom_processinginstruction_class_entry->name, &dom_processinginstruction_prop_handlers);
#ifdef LIBXML_XPATH_ENABLED
memcpy(&dom_xpath_object_handlers, &dom_object_handlers, sizeof(zend_object_handlers));
dom_xpath_object_handlers.offset = XtOffsetOf(dom_xpath_object, dom) + XtOffsetOf(dom_object, std);
dom_xpath_object_handlers.free_obj = dom_xpath_objects_free_storage;
- INIT_CLASS_ENTRY(ce, "DOMXPath", class_DOMXPath_methods);
- ce.create_object = dom_xpath_objects_new;
- dom_xpath_class_entry = zend_register_internal_class_ex(&ce, NULL);
+ dom_xpath_class_entry = register_class_DOMXPath();
+ dom_xpath_class_entry->create_object = dom_xpath_objects_new;
zend_hash_init(&dom_xpath_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
dom_register_prop_handler(&dom_xpath_prop_handlers, "document", sizeof("document")-1, dom_xpath_document_read, NULL);
dom_register_prop_handler(&dom_xpath_prop_handlers, "registerNodeNamespaces", sizeof("registerNodeNamespaces")-1, dom_xpath_register_node_ns_read, dom_xpath_register_node_ns_write);
- zend_hash_add_ptr(&classes, ce.name, &dom_xpath_prop_handlers);
+ zend_hash_add_ptr(&classes, dom_xpath_class_entry->name, &dom_xpath_prop_handlers);
#endif
REGISTER_LONG_CONSTANT("XML_ELEMENT_NODE", XML_ELEMENT_NODE, CONST_CS | CONST_PERSISTENT);
@@ -1125,7 +1123,7 @@ void php_dom_create_iterator(zval *return_value, int ce_type) /* {{{ */
/* }}} */
/* {{{ php_dom_create_object */
-PHP_DOM_EXPORT zend_bool php_dom_create_object(xmlNodePtr obj, zval *return_value, dom_object *domobj)
+PHP_DOM_EXPORT bool php_dom_create_object(xmlNodePtr obj, zval *return_value, dom_object *domobj)
{
zend_class_entry *ce;
dom_object *intern;
@@ -1305,10 +1303,10 @@ xmlNode *dom_get_elements_by_tag_name_ns_raw(xmlNodePtr nodep, char *ns, char *l
/* }}} */
/* }}} end dom_element_get_elements_by_tag_name_ns_raw */
-static inline zend_bool is_empty_node(xmlNodePtr nodep)
+static inline bool is_empty_node(xmlNodePtr nodep)
{
xmlChar *strContent = xmlNodeGetContent(nodep);
- zend_bool ret = strContent == NULL || *strContent == '\0';
+ bool ret = strContent == NULL || *strContent == '\0';
xmlFree(strContent);
return ret;
}
diff --git a/ext/dom/php_dom.h b/ext/dom/php_dom.h
index 24e1ea646a..0c5fc9778f 100644
--- a/ext/dom/php_dom.h
+++ b/ext/dom/php_dom.h
@@ -132,11 +132,6 @@ void dom_parent_node_after(dom_object *context, zval *nodes, int nodesc);
void dom_parent_node_before(dom_object *context, zval *nodes, int nodesc);
void dom_child_node_remove(dom_object *context);
-#define REGISTER_DOM_CLASS(ce, name, parent_ce, funcs, entry) \
-INIT_CLASS_ENTRY(ce, name, funcs); \
-ce.create_object = dom_objects_new; \
-entry = zend_register_internal_class_ex(&ce, parent_ce);
-
#define DOM_GET_OBJ(__ptr, __id, __prtype, __intern) { \
__intern = Z_DOMOBJ_P(__id); \
if (__intern->ptr == NULL || !(__ptr = (__prtype)((php_libxml_node_ptr *)__intern->ptr)->node)) { \
diff --git a/ext/dom/php_dom.stub.php b/ext/dom/php_dom.stub.php
index 2a9a9cff80..72c63883fc 100644
--- a/ext/dom/php_dom.stub.php
+++ b/ext/dom/php_dom.stub.php
@@ -1,6 +1,6 @@
<?php
-/** @generate-function-entries */
+/** @generate-class-entries */
class DOMDocumentType extends DOMNode
{
@@ -360,6 +360,8 @@ class DOMDocument extends DOMNode implements DOMParentNode
final class DOMException extends Exception
{
+ /** @var int */
+ public $code = 0;
}
class DOMText extends DOMCharacterData
diff --git a/ext/dom/php_dom_arginfo.h b/ext/dom/php_dom_arginfo.h
index c3c54a4de7..b6e621b1bc 100644
--- a/ext/dom/php_dom_arginfo.h
+++ b/ext/dom/php_dom_arginfo.h
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: a4767d6ea60859c8897f681fb69d6f73b1f50471 */
+ * Stub hash: c41e6d58eb8b0bbdb07401c4f1eb92c6ba3d324c */
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_dom_import_simplexml, 0, 1, DOMElement, 1)
ZEND_ARG_TYPE_INFO(0, node, IS_OBJECT, 0)
@@ -847,3 +847,236 @@ static const zend_function_entry class_DOMXPath_methods[] = {
#endif
ZEND_FE_END
};
+
+static zend_class_entry *register_class_DOMDocumentType(zend_class_entry *class_entry_DOMNode)
+{
+ zend_class_entry ce, *class_entry;
+
+ INIT_CLASS_ENTRY(ce, "DOMDocumentType", class_DOMDocumentType_methods);
+ class_entry = zend_register_internal_class_ex(&ce, class_entry_DOMNode);
+
+ return class_entry;
+}
+
+static zend_class_entry *register_class_DOMCdataSection(zend_class_entry *class_entry_DOMText)
+{
+ zend_class_entry ce, *class_entry;
+
+ INIT_CLASS_ENTRY(ce, "DOMCdataSection", class_DOMCdataSection_methods);
+ class_entry = zend_register_internal_class_ex(&ce, class_entry_DOMText);
+
+ return class_entry;
+}
+
+static zend_class_entry *register_class_DOMComment(zend_class_entry *class_entry_DOMCharacterData)
+{
+ zend_class_entry ce, *class_entry;
+
+ INIT_CLASS_ENTRY(ce, "DOMComment", class_DOMComment_methods);
+ class_entry = zend_register_internal_class_ex(&ce, class_entry_DOMCharacterData);
+
+ return class_entry;
+}
+
+static zend_class_entry *register_class_DOMParentNode(void)
+{
+ zend_class_entry ce, *class_entry;
+
+ INIT_CLASS_ENTRY(ce, "DOMParentNode", class_DOMParentNode_methods);
+ class_entry = zend_register_internal_interface(&ce);
+
+ return class_entry;
+}
+
+static zend_class_entry *register_class_DOMChildNode(void)
+{
+ zend_class_entry ce, *class_entry;
+
+ INIT_CLASS_ENTRY(ce, "DOMChildNode", class_DOMChildNode_methods);
+ class_entry = zend_register_internal_interface(&ce);
+
+ return class_entry;
+}
+
+static zend_class_entry *register_class_DOMNode(void)
+{
+ zend_class_entry ce, *class_entry;
+
+ INIT_CLASS_ENTRY(ce, "DOMNode", class_DOMNode_methods);
+ class_entry = zend_register_internal_class_ex(&ce, NULL);
+
+ return class_entry;
+}
+
+static zend_class_entry *register_class_DOMNameSpaceNode(void)
+{
+ zend_class_entry ce, *class_entry;
+
+ INIT_CLASS_ENTRY(ce, "DOMNameSpaceNode", class_DOMNameSpaceNode_methods);
+ class_entry = zend_register_internal_class_ex(&ce, NULL);
+
+ return class_entry;
+}
+
+static zend_class_entry *register_class_DOMImplementation(void)
+{
+ zend_class_entry ce, *class_entry;
+
+ INIT_CLASS_ENTRY(ce, "DOMImplementation", class_DOMImplementation_methods);
+ class_entry = zend_register_internal_class_ex(&ce, NULL);
+
+ return class_entry;
+}
+
+static zend_class_entry *register_class_DOMDocumentFragment(zend_class_entry *class_entry_DOMNode, zend_class_entry *class_entry_DOMParentNode)
+{
+ zend_class_entry ce, *class_entry;
+
+ INIT_CLASS_ENTRY(ce, "DOMDocumentFragment", class_DOMDocumentFragment_methods);
+ class_entry = zend_register_internal_class_ex(&ce, class_entry_DOMNode);
+ zend_class_implements(class_entry, 1, class_entry_DOMParentNode);
+
+ return class_entry;
+}
+
+static zend_class_entry *register_class_DOMNodeList(zend_class_entry *class_entry_IteratorAggregate, zend_class_entry *class_entry_Countable)
+{
+ zend_class_entry ce, *class_entry;
+
+ INIT_CLASS_ENTRY(ce, "DOMNodeList", class_DOMNodeList_methods);
+ class_entry = zend_register_internal_class_ex(&ce, NULL);
+ zend_class_implements(class_entry, 2, class_entry_IteratorAggregate, class_entry_Countable);
+
+ return class_entry;
+}
+
+static zend_class_entry *register_class_DOMCharacterData(zend_class_entry *class_entry_DOMNode, zend_class_entry *class_entry_DOMChildNode)
+{
+ zend_class_entry ce, *class_entry;
+
+ INIT_CLASS_ENTRY(ce, "DOMCharacterData", class_DOMCharacterData_methods);
+ class_entry = zend_register_internal_class_ex(&ce, class_entry_DOMNode);
+ zend_class_implements(class_entry, 1, class_entry_DOMChildNode);
+
+ return class_entry;
+}
+
+static zend_class_entry *register_class_DOMAttr(zend_class_entry *class_entry_DOMNode)
+{
+ zend_class_entry ce, *class_entry;
+
+ INIT_CLASS_ENTRY(ce, "DOMAttr", class_DOMAttr_methods);
+ class_entry = zend_register_internal_class_ex(&ce, class_entry_DOMNode);
+
+ return class_entry;
+}
+
+static zend_class_entry *register_class_DOMElement(zend_class_entry *class_entry_DOMNode, zend_class_entry *class_entry_DOMParentNode, zend_class_entry *class_entry_DOMChildNode)
+{
+ zend_class_entry ce, *class_entry;
+
+ INIT_CLASS_ENTRY(ce, "DOMElement", class_DOMElement_methods);
+ class_entry = zend_register_internal_class_ex(&ce, class_entry_DOMNode);
+ zend_class_implements(class_entry, 2, class_entry_DOMParentNode, class_entry_DOMChildNode);
+
+ return class_entry;
+}
+
+static zend_class_entry *register_class_DOMDocument(zend_class_entry *class_entry_DOMNode, zend_class_entry *class_entry_DOMParentNode)
+{
+ zend_class_entry ce, *class_entry;
+
+ INIT_CLASS_ENTRY(ce, "DOMDocument", class_DOMDocument_methods);
+ class_entry = zend_register_internal_class_ex(&ce, class_entry_DOMNode);
+ zend_class_implements(class_entry, 1, class_entry_DOMParentNode);
+
+ return class_entry;
+}
+
+static zend_class_entry *register_class_DOMException(zend_class_entry *class_entry_Exception)
+{
+ zend_class_entry ce, *class_entry;
+
+ INIT_CLASS_ENTRY(ce, "DOMException", class_DOMException_methods);
+ class_entry = zend_register_internal_class_ex(&ce, class_entry_Exception);
+ class_entry->ce_flags |= ZEND_ACC_FINAL;
+
+ zval property_code_default_value;
+ ZVAL_LONG(&property_code_default_value, 0);
+ zend_string *property_code_name = zend_string_init("code", sizeof("code") - 1, 1);
+ zend_declare_property_ex(class_entry, property_code_name, &property_code_default_value, ZEND_ACC_PUBLIC, NULL);
+ zend_string_release(property_code_name);
+
+ return class_entry;
+}
+
+static zend_class_entry *register_class_DOMText(zend_class_entry *class_entry_DOMCharacterData)
+{
+ zend_class_entry ce, *class_entry;
+
+ INIT_CLASS_ENTRY(ce, "DOMText", class_DOMText_methods);
+ class_entry = zend_register_internal_class_ex(&ce, class_entry_DOMCharacterData);
+
+ return class_entry;
+}
+
+static zend_class_entry *register_class_DOMNamedNodeMap(zend_class_entry *class_entry_IteratorAggregate, zend_class_entry *class_entry_Countable)
+{
+ zend_class_entry ce, *class_entry;
+
+ INIT_CLASS_ENTRY(ce, "DOMNamedNodeMap", class_DOMNamedNodeMap_methods);
+ class_entry = zend_register_internal_class_ex(&ce, NULL);
+ zend_class_implements(class_entry, 2, class_entry_IteratorAggregate, class_entry_Countable);
+
+ return class_entry;
+}
+
+static zend_class_entry *register_class_DOMEntity(zend_class_entry *class_entry_DOMNode)
+{
+ zend_class_entry ce, *class_entry;
+
+ INIT_CLASS_ENTRY(ce, "DOMEntity", class_DOMEntity_methods);
+ class_entry = zend_register_internal_class_ex(&ce, class_entry_DOMNode);
+
+ return class_entry;
+}
+
+static zend_class_entry *register_class_DOMEntityReference(zend_class_entry *class_entry_DOMNode)
+{
+ zend_class_entry ce, *class_entry;
+
+ INIT_CLASS_ENTRY(ce, "DOMEntityReference", class_DOMEntityReference_methods);
+ class_entry = zend_register_internal_class_ex(&ce, class_entry_DOMNode);
+
+ return class_entry;
+}
+
+static zend_class_entry *register_class_DOMNotation(zend_class_entry *class_entry_DOMNode)
+{
+ zend_class_entry ce, *class_entry;
+
+ INIT_CLASS_ENTRY(ce, "DOMNotation", class_DOMNotation_methods);
+ class_entry = zend_register_internal_class_ex(&ce, class_entry_DOMNode);
+
+ return class_entry;
+}
+
+static zend_class_entry *register_class_DOMProcessingInstruction(zend_class_entry *class_entry_DOMNode)
+{
+ zend_class_entry ce, *class_entry;
+
+ INIT_CLASS_ENTRY(ce, "DOMProcessingInstruction", class_DOMProcessingInstruction_methods);
+ class_entry = zend_register_internal_class_ex(&ce, class_entry_DOMNode);
+
+ return class_entry;
+}
+
+static zend_class_entry *register_class_DOMXPath(void)
+{
+ zend_class_entry ce, *class_entry;
+
+ INIT_CLASS_ENTRY(ce, "DOMXPath", class_DOMXPath_methods);
+ class_entry = zend_register_internal_class_ex(&ce, NULL);
+
+ return class_entry;
+}
diff --git a/ext/dom/processinginstruction.c b/ext/dom/processinginstruction.c
index 73367442eb..9c4e208387 100644
--- a/ext/dom/processinginstruction.c
+++ b/ext/dom/processinginstruction.c
@@ -75,7 +75,7 @@ int dom_processinginstruction_target_read(dom_object *obj, zval *retval)
xmlNodePtr nodep = dom_object_get_node(obj);
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -99,7 +99,7 @@ int dom_processinginstruction_data_read(dom_object *obj, zval *retval)
nodep = dom_object_get_node(obj);
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
@@ -119,7 +119,7 @@ int dom_processinginstruction_data_write(dom_object *obj, zval *newval)
zend_string *str;
if (nodep == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
diff --git a/ext/dom/tests/DOMCharacterData_data_error_002.phpt b/ext/dom/tests/DOMCharacterData_data_error_002.phpt
index 401e0f2f8c..a88ee509bf 100644
--- a/ext/dom/tests/DOMCharacterData_data_error_002.phpt
+++ b/ext/dom/tests/DOMCharacterData_data_error_002.phpt
@@ -8,7 +8,11 @@ Eric Berg <ehberg@gmail.com>
--FILE--
<?php
$character_data = new DOMCharacterData();
-print $character_data->data;
+try {
+ print $character_data->data;
+} catch (DOMException $exception) {
+ echo $exception->getMessage() . "\n";
+}
?>
---EXPECTF--
-Warning: main(): Invalid State Error in %s on line %d
+--EXPECT--
+Invalid State Error
diff --git a/ext/dom/tests/DOMCharacterData_length_error_001.phpt b/ext/dom/tests/DOMCharacterData_length_error_001.phpt
index 34d5273be4..79d936bdd0 100644
--- a/ext/dom/tests/DOMCharacterData_length_error_001.phpt
+++ b/ext/dom/tests/DOMCharacterData_length_error_001.phpt
@@ -8,7 +8,11 @@ Jason Bouffard <jbouffard1@yahoo.com>
--FILE--
<?php
$character_data = new DOMCharacterData();
-print $character_data->length;
+try {
+ print $character_data->length;
+} catch (DOMException $exception) {
+ echo $exception->getMessage() . "\n";
+}
?>
---EXPECTF--
-Warning: main(): Invalid State Error in %s
+--EXPECT--
+Invalid State Error
diff --git a/ext/dom/tests/DOMDocumentType_entities_error_001.phpt b/ext/dom/tests/DOMDocumentType_entities_error_001.phpt
index 4d047a0058..f93ae21386 100644
--- a/ext/dom/tests/DOMDocumentType_entities_error_001.phpt
+++ b/ext/dom/tests/DOMDocumentType_entities_error_001.phpt
@@ -8,7 +8,11 @@ Eric Lee Stewart <ericleestewart@gmail.com>
--FILE--
<?php
$doctype = new DOMDocumentType();
-$entities = $doctype->entities;
+try {
+ $doctype->entities;
+} catch (DOMException $exception) {
+ echo $exception->getMessage() . "\n";
+}
?>
---EXPECTF--
-Warning: main(): Invalid State Error in %s on line %d
+--EXPECT--
+Invalid State Error
diff --git a/ext/dom/tests/DOMDocumentType_internalSubset_error_001.phpt b/ext/dom/tests/DOMDocumentType_internalSubset_error_001.phpt
index 5825914777..b05712ce24 100644
--- a/ext/dom/tests/DOMDocumentType_internalSubset_error_001.phpt
+++ b/ext/dom/tests/DOMDocumentType_internalSubset_error_001.phpt
@@ -8,7 +8,11 @@ Eric Lee Stewart <ericleestewart@gmail.com>
--FILE--
<?php
$doctype = new DOMDocumentType();
-$internalSubset = $doctype->internalSubset;
+try {
+ $doctype->internalSubset;
+} catch (DOMException $exception) {
+ echo $exception->getMessage() . "\n";
+}
?>
---EXPECTF--
-Warning: main(): Invalid State Error in %s on line %d
+--EXPECT--
+Invalid State Error
diff --git a/ext/dom/tests/DOMDocumentType_name_error_001.phpt b/ext/dom/tests/DOMDocumentType_name_error_001.phpt
index 026ea2393a..7eda99dca5 100644
--- a/ext/dom/tests/DOMDocumentType_name_error_001.phpt
+++ b/ext/dom/tests/DOMDocumentType_name_error_001.phpt
@@ -8,7 +8,11 @@ Eric Lee Stewart <ericleestewart@gmail.com>
--FILE--
<?php
$doctype = new DOMDocumentType();
-$name = $doctype->name;
+try {
+ $doctype->name;
+} catch (DOMException $exception) {
+ echo $exception->getMessage() . "\n";
+}
?>
---EXPECTF--
-Warning: main(): Invalid State Error in %s on line %d
+--EXPECT--
+Invalid State Error
diff --git a/ext/dom/tests/DOMDocumentType_notations_error_001.phpt b/ext/dom/tests/DOMDocumentType_notations_error_001.phpt
index a18f47f3f1..53b8c9c0d1 100644
--- a/ext/dom/tests/DOMDocumentType_notations_error_001.phpt
+++ b/ext/dom/tests/DOMDocumentType_notations_error_001.phpt
@@ -8,7 +8,11 @@ Eric Lee Stewart <ericleestewart@gmail.com>
--FILE--
<?php
$doctype = new DOMDocumentType();
-$notations = $doctype->notations;
+try {
+ $notations = $doctype->notations;
+} catch (DOMException $exception) {
+ echo $exception->getMessage() . "\n";
+}
?>
---EXPECTF--
-Warning: main(): Invalid State Error in %s on line %d
+--EXPECT--
+Invalid State Error
diff --git a/ext/dom/tests/DOMDocumentType_publicId_error_001.phpt b/ext/dom/tests/DOMDocumentType_publicId_error_001.phpt
index df6c2bd908..c46f94faeb 100644
--- a/ext/dom/tests/DOMDocumentType_publicId_error_001.phpt
+++ b/ext/dom/tests/DOMDocumentType_publicId_error_001.phpt
@@ -8,7 +8,11 @@ Eric Lee Stewart <ericleestewart@gmail.com>
--FILE--
<?php
$doctype = new DOMDocumentType();
-$publicId = $doctype->publicId;
+try {
+ $publicId = $doctype->publicId;
+} catch (DOMException $exception) {
+ echo $exception->getMessage() . "\n";
+}
?>
---EXPECTF--
-Warning: main(): Invalid State Error in %s on line %d
+--EXPECT--
+Invalid State Error
diff --git a/ext/dom/tests/DOMDocumentType_systemId_error_001.phpt b/ext/dom/tests/DOMDocumentType_systemId_error_001.phpt
index e302fcc7f1..a8dfe3bdfb 100644
--- a/ext/dom/tests/DOMDocumentType_systemId_error_001.phpt
+++ b/ext/dom/tests/DOMDocumentType_systemId_error_001.phpt
@@ -8,7 +8,11 @@ Eric Lee Stewart <ericleestewart@gmail.com>
--FILE--
<?php
$doctype = new DOMDocumentType();
-$systemId = $doctype->systemId;
+try {
+ $systemId = $doctype->systemId;
+} catch (DOMException $exception) {
+ echo $exception->getMessage() . "\n";
+}
?>
---EXPECTF--
-Warning: main(): Invalid State Error in %s on line %d
+--EXPECT--
+Invalid State Error
diff --git a/ext/dom/tests/DOMDocument_saveHTMLFile_invalid_filename.phpt b/ext/dom/tests/DOMDocument_saveHTMLFile_invalid_filename.phpt
index 12b45a491b..4e724585f1 100644
--- a/ext/dom/tests/DOMDocument_saveHTMLFile_invalid_filename.phpt
+++ b/ext/dom/tests/DOMDocument_saveHTMLFile_invalid_filename.phpt
@@ -9,7 +9,7 @@ require_once __DIR__ .'/skipif.inc';
?>
--FILE--
<?php
-$filename = null;
+$filename = '';
$doc = new DOMDocument('1.0');
$root = $doc->createElement('html');
$root = $doc->appendChild($root);
diff --git a/ext/dom/tests/dom003.phpt b/ext/dom/tests/dom003.phpt
index 20db09d40e..d846995db5 100644
--- a/ext/dom/tests/dom003.phpt
+++ b/ext/dom/tests/dom003.phpt
@@ -30,6 +30,8 @@ object(DOMException)#%d (%d) {
string(23) "Hierarchy Request Error"
["string":"Exception":private]=>
string(0) ""
+ ["code"]=>
+ int(3)
["file":protected]=>
string(%d) "%sdom003.php"
["line":protected]=>
@@ -57,8 +59,6 @@ object(DOMException)#%d (%d) {
}
["previous":"Exception":private]=>
NULL
- ["code"]=>
- int(3)
}
--- Don't catch exception with try/catch
diff --git a/ext/dom/tests/dom_set_attr_node.phpt b/ext/dom/tests/dom_set_attr_node.phpt
index 6160cd48f2..bb573ffda0 100644
--- a/ext/dom/tests/dom_set_attr_node.phpt
+++ b/ext/dom/tests/dom_set_attr_node.phpt
@@ -40,6 +40,8 @@ object(DOMException)#%d (7) {
string(20) "Wrong Document Error"
["string":"Exception":private]=>
string(0) ""
+ ["code"]=>
+ int(4)
["file":protected]=>
string(%d) "%sdom_set_attr_node.php"
["line":protected]=>
@@ -67,6 +69,4 @@ object(DOMException)#%d (7) {
}
["previous":"Exception":private]=>
NULL
- ["code"]=>
- int(4)
}
diff --git a/ext/dom/text.c b/ext/dom/text.c
index 7a45be2463..c19d3e9194 100644
--- a/ext/dom/text.c
+++ b/ext/dom/text.c
@@ -74,7 +74,7 @@ int dom_text_whole_text_read(dom_object *obj, zval *retval)
node = dom_object_get_node(obj);
if (node == NULL) {
- php_dom_throw_error(INVALID_STATE_ERR, 0);
+ php_dom_throw_error(INVALID_STATE_ERR, 1);
return FAILURE;
}
diff --git a/ext/dom/xml_common.h b/ext/dom/xml_common.h
index 40548c2d1a..671710e2e8 100644
--- a/ext/dom/xml_common.h
+++ b/ext/dom/xml_common.h
@@ -53,7 +53,7 @@ static inline dom_object *php_dom_obj_from_obj(zend_object *obj) {
PHP_DOM_EXPORT extern zend_class_entry *dom_node_class_entry;
PHP_DOM_EXPORT dom_object *php_dom_object_get_data(xmlNodePtr obj);
-PHP_DOM_EXPORT zend_bool php_dom_create_object(xmlNodePtr obj, zval* return_value, dom_object *domobj);
+PHP_DOM_EXPORT bool php_dom_create_object(xmlNodePtr obj, zval* return_value, dom_object *domobj);
PHP_DOM_EXPORT xmlNodePtr dom_object_get_node(dom_object *obj);
#define DOM_XMLNS_NAMESPACE \
diff --git a/ext/dom/xpath.c b/ext/dom/xpath.c
index 1f97601c42..6ea3533188 100644
--- a/ext/dom/xpath.c
+++ b/ext/dom/xpath.c
@@ -208,7 +208,7 @@ static void dom_xpath_ext_function_object_php(xmlXPathParserContextPtr ctxt, int
PHP_METHOD(DOMXPath, __construct)
{
zval *doc;
- zend_bool register_node_ns = 1;
+ bool register_node_ns = 1;
xmlDocPtr docp = NULL;
dom_object *docobj;
dom_xpath_object *intern;
@@ -335,7 +335,7 @@ static void php_xpath_eval(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */
char *expr;
xmlDoc *docp = NULL;
xmlNsPtr *ns = NULL;
- zend_bool register_node_ns;
+ bool register_node_ns;
id = ZEND_THIS;
intern = Z_XPATHOBJ_P(id);