From: Marcus Boerger Date: Sat, 29 Oct 2005 16:12:57 +0000 (+0000) Subject: - Change var_dump to include all that is reachable, incl. @attributes X-Git-Tag: RELEASE_2_0_1~120 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b4762f13f1180c40fa15ffb8fdefa3b4acd3c276;p=php - Change var_dump to include all that is reachable, incl. @attributes - Adapt tests and add new one --- diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 980c33da50..9d73df2ebb 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -38,6 +38,8 @@ #include "ext/spl/spl_sxe.h" #endif +#define SXE_ELEMENT_BY_NAME 0 + zend_class_entry *sxe_class_entry = NULL; ZEND_API zend_class_entry *sxe_get_element_class_entry(TSRMLS_D) @@ -112,10 +114,7 @@ static xmlNodePtr php_sxe_get_first_node(php_sxe_object *sxe, xmlNodePtr node TS } } -/* {{{ match_ns() - */ -static inline int -match_ns(php_sxe_object *sxe, xmlNodePtr node, xmlChar *name) +static inline int match_ns(php_sxe_object *sxe, xmlNodePtr node, xmlChar *name) /* {{{ */ { if (name == NULL && (node->ns == NULL || node->ns->prefix == NULL)) { return 1; @@ -129,9 +128,8 @@ match_ns(php_sxe_object *sxe, xmlNodePtr node, xmlChar *name) } /* }}} */ -/* {{{ sxe_get_element_node() - */ -static xmlNodePtr sxe_get_element_by_offset(php_sxe_object *sxe, long offset, xmlNodePtr node) { +static xmlNodePtr sxe_get_element_by_offset(php_sxe_object *sxe, long offset, xmlNodePtr node) /* {{{ */ +{ long nodendx = 0; if (sxe->iter.type == SXE_ITER_NONE) { @@ -156,6 +154,71 @@ next_iter: } /* }}} */ +#if SXE_ELEMENT_BY_NAME +static xmlNodePtr sxe_find_element_by_name(php_sxe_object *sxe, xmlNodePtr node, char *name TSRMLS_DC) /* {{{ */ +{ + while (node) { + SKIP_TEXT(node) + if (node->type == XML_ELEMENT_NODE && match_ns(sxe, node, sxe->iter.nsprefix)) { + if (!xmlStrcmp(node->name, name)) { + return node; + } + } +next_iter: + node = node->next; + } + return NULL; +} /* }}} */ + +static xmlNodePtr sxe_get_element_by_name(php_sxe_object *sxe, xmlNodePtr node, char **name, int *type TSRMLS_DC) /* {{{ */ +{ + int orgtype; + xmlNodePtr orgnode = node; + xmlNodePtr retnode = NULL; + + if (sxe->iter.type != SXE_ITER_ATTRLIST) + { + orgtype = sxe->iter.type; + if (sxe->iter.type == SXE_ITER_NONE) { + sxe->iter.type = SXE_ITER_CHILD; + } + node = php_sxe_get_first_node(sxe, node TSRMLS_CC); + sxe->iter.type = orgtype; + } + + if (sxe->iter.type == SXE_ITER_ELEMENT) { + orgnode = sxe_find_element_by_name(sxe, node, sxe->iter.name TSRMLS_CC); + node = orgnode->children; + } + + while (node) { + SKIP_TEXT(node) + if (node->type == XML_ELEMENT_NODE && match_ns(sxe, node, sxe->iter.nsprefix)) { + if (!xmlStrcmp(node->name, *name)) { + if (1||retnode) + { + *type = SXE_ITER_ELEMENT; + return orgnode; + } + retnode = node; + } + } +next_iter: + node = node->next; + } + + if (retnode) + { + *type = SXE_ITER_NONE; + *name = NULL; + return retnode; + } + + return NULL; +} +/* }}} */ +#endif /* SXE_ELEMENT_BY_NAME */ + /* {{{ sxe_prop_dim_read() */ static zval * sxe_prop_dim_read(zval *object, zval *member, zend_bool elements, zend_bool attribs, zend_bool silent TSRMLS_DC) @@ -166,7 +229,7 @@ static zval * sxe_prop_dim_read(zval *object, zval *member, zend_bool elements, xmlNodePtr node; xmlAttrPtr attr; zval tmp_zv; - int nodendx = 0; + int nodendx = 0; sxe = php_sxe_fetch_object(object TSRMLS_CC); @@ -175,6 +238,7 @@ static zval * sxe_prop_dim_read(zval *object, zval *member, zend_bool elements, attribs = 0; elements = 1; } + name = NULL; } else { if (Z_TYPE_P(member) != IS_STRING) { tmp_zv = *member; @@ -182,24 +246,23 @@ static zval * sxe_prop_dim_read(zval *object, zval *member, zend_bool elements, member = &tmp_zv; convert_to_string(member); } + name = Z_STRVAL_P(member); } MAKE_STD_ZVAL(return_value); ZVAL_NULL(return_value); - name = Z_STRVAL_P(member); - GET_NODE(sxe, node); - if (sxe->iter.type != SXE_ITER_CHILD && sxe->iter.type != SXE_ITER_ATTRLIST) { + if (sxe->iter.type == SXE_ITER_ATTRLIST) { + attribs = 1; + elements = 0; + } else if (sxe->iter.type != SXE_ITER_CHILD && sxe->iter.type != SXE_ITER_ATTRLIST) { node = php_sxe_get_first_node(sxe, node TSRMLS_CC); } - if (node) { if (attribs) { - if (Z_TYPE_P(member) == IS_LONG && sxe->iter.type != SXE_ITER_ATTRLIST) { - attr = NULL; - } else { + if (Z_TYPE_P(member) != IS_LONG || sxe->iter.type == SXE_ITER_ATTRLIST) { attr = node->properties; if (Z_TYPE_P(member) == IS_LONG) { while (attr && nodendx <= Z_LVAL_P(member)) { @@ -237,7 +300,17 @@ static zval * sxe_prop_dim_read(zval *object, zval *member, zend_bool elements, _node_as_zval(sxe, node, return_value, SXE_ITER_NONE, NULL, sxe->iter.nsprefix TSRMLS_CC); } } else { +#if SXE_ELEMENT_BY_NAME + int newtype; + + GET_NODE(sxe, node); + node = sxe_get_element_by_name(sxe, node, &name, &newtype TSRMLS_CC); + if (node) { + _node_as_zval(sxe, node, return_value, newtype, name, sxe->iter.nsprefix TSRMLS_CC); + } +#else _node_as_zval(sxe, node, return_value, SXE_ITER_ELEMENT, name, sxe->iter.nsprefix TSRMLS_CC); +#endif } } } @@ -671,19 +744,41 @@ _get_base_node_value(php_sxe_object *sxe_ref, xmlNodePtr node, zval **value, cha } /* }}} */ +static void sxe_properties_add(HashTable *rv, char *name, int namelen, zval *value TSRMLS_DC) +{ + zval **data_ptr; + zval *newptr; + ulong h = zend_hash_func(name, namelen); + + if (zend_hash_quick_find(rv, name, namelen, h, (void **) &data_ptr) == SUCCESS) { + if (Z_TYPE_PP(data_ptr) == IS_ARRAY) { + zend_hash_next_index_insert(Z_ARRVAL_PP(data_ptr), &value, sizeof(zval *), NULL); + } else { + MAKE_STD_ZVAL(newptr); + array_init(newptr); + + zval_add_ref(data_ptr); + zend_hash_next_index_insert(Z_ARRVAL_P(newptr), data_ptr, sizeof(zval *), NULL); + zend_hash_next_index_insert(Z_ARRVAL_P(newptr), &value, sizeof(zval *), NULL); + + zend_hash_quick_update(rv, name, namelen, h, &newptr, sizeof(zval *), NULL); + } + } else { + zend_hash_quick_update(rv, name, namelen, h, &value, sizeof(zval *), NULL); + } +} + /* {{{ sxe_properties_get() */ -static HashTable * -sxe_properties_get(zval *object TSRMLS_DC) +static HashTable * sxe_properties_get(zval *object TSRMLS_DC) { - zval **data_ptr; zval *value; - zval *newptr; + zval *zattr; HashTable *rv; php_sxe_object *sxe; char *name; xmlNodePtr node; - ulong h; + xmlAttrPtr attr; int namelen; sxe = php_sxe_fetch_object(object TSRMLS_CC); @@ -698,9 +793,31 @@ sxe_properties_get(zval *object TSRMLS_DC) } GET_NODE(sxe, node); - node = php_sxe_get_first_node(sxe, node TSRMLS_CC); + if (1||sxe->iter.type != SXE_ITER_CHILD) { + if (sxe->iter.type == SXE_ITER_ELEMENT) { + node = php_sxe_get_first_node(sxe, node TSRMLS_CC); + } + attr = node ? (xmlAttrPtr)node->properties : NULL; + zattr = NULL; + while (attr) { + if (match_ns(sxe, (xmlNodePtr)attr, sxe->iter.nsprefix)) { + MAKE_STD_ZVAL(value); + ZVAL_STRING(value, xmlNodeListGetString((xmlDocPtr) sxe->document->ptr, attr->children, 1), 1); + namelen = xmlStrlen(attr->name) + 1; + if (!zattr) { + MAKE_STD_ZVAL(zattr); + array_init(zattr); + sxe_properties_add(rv, "@attributes", sizeof("@attributes"), zattr TSRMLS_CC); + } + add_assoc_zval_ex(zattr, (char*)attr->name, namelen, value); + } + attr = attr->next; + } + } - if (node) { + GET_NODE(sxe, node); + node = php_sxe_get_first_node(sxe, node TSRMLS_CC); + if (node && sxe->iter.type != SXE_ITER_ATTRLIST) { if (node->type == XML_ATTRIBUTE_NODE) { MAKE_STD_ZVAL(value); ZVAL_U_STRING(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), value, xmlNodeListGetString(node->doc, node->children, 1), 1); @@ -735,24 +852,7 @@ sxe_properties_get(zval *object TSRMLS_DC) _get_base_node_value(sxe, node, &value, sxe->iter.nsprefix TSRMLS_CC); - h = zend_hash_func(name, namelen); - if (zend_hash_quick_find(rv, name, namelen, h, (void **) &data_ptr) == SUCCESS) { - if (Z_TYPE_PP(data_ptr) == IS_ARRAY) { - zend_hash_next_index_insert(Z_ARRVAL_PP(data_ptr), &value, sizeof(zval *), NULL); - } else { - MAKE_STD_ZVAL(newptr); - array_init(newptr); - - zval_add_ref(data_ptr); - zend_hash_next_index_insert(Z_ARRVAL_P(newptr), data_ptr, sizeof(zval *), NULL); - zend_hash_next_index_insert(Z_ARRVAL_P(newptr), &value, sizeof(zval *), NULL); - - zend_hash_quick_update(rv, name, namelen, h, &newptr, sizeof(zval *), NULL); - } - } else { - zend_hash_quick_update(rv, name, namelen, h, &value, sizeof(zval *), NULL); - } - + sxe_properties_add(rv, name, namelen, value TSRMLS_CC); next_iter: node = node->next; } @@ -1007,8 +1107,7 @@ SXE_METHOD(attributes) /* {{{ cast_object() */ -static int -cast_object(zval *object, int type, char *contents TSRMLS_DC) +static int cast_object(zval *object, int type, char *contents TSRMLS_DC) { if (contents) { ZVAL_STRINGL(object, contents, strlen(contents), 1); @@ -1046,8 +1145,7 @@ cast_object(zval *object, int type, char *contents TSRMLS_DC) /* {{{ sxe_object_cast() */ -static int -sxe_object_cast(zval *readobj, zval *writeobj, int type TSRMLS_DC) +static int sxe_object_cast(zval *readobj, zval *writeobj, int type TSRMLS_DC) { php_sxe_object *sxe; char *contents = NULL; diff --git a/ext/simplexml/tests/000.phpt b/ext/simplexml/tests/000.phpt new file mode 100755 index 0000000000..0499bcd541 --- /dev/null +++ b/ext/simplexml/tests/000.phpt @@ -0,0 +1,220 @@ +--TEST-- +SimpleXML: var_dump() +--SKIPIF-- + +--FILE-- +elem1'); +test('sxe->elem1[0]'); +test('sxe->elem1[0]->elem2'); +test('sxe->elem1[0]->elem2->bla'); +test('sxe->elem1[0]["attr1"]'); +test('sxe->elem1[0]->attr1'); +test('sxe->elem1[1]'); +test('sxe->elem1[2]'); +test('sxe->elem11'); +test('sxe->elem11->elem111'); +test('sxe->elem11->elem111->elem1111'); +test('sxe->elem22'); +test('sxe->elem22->elem222'); +test('sxe->elem22->attr22'); +test('sxe->elem22["attr22"]'); + +?> +===DONE=== + +--EXPECTF-- +===sxe +bool(true) +object(SimpleXMLElement)#%d (3) { + ["@attributes"]=> + array(1) { + ["id"]=> + string(3) "123" + } + ["elem1"]=> + array(2) { + [0]=> + string(36) "There is some text.Here is some more" + [1]=> + object(SimpleXMLElement)#%d (1) { + ["@attributes"]=> + array(2) { + ["attr1"]=> + string(2) "11" + ["attr2"]=> + string(2) "12" + } + } + } + ["elem11"]=> + object(SimpleXMLElement)#%d (1) { + ["elem111"]=> + object(SimpleXMLElement)#%d (1) { + ["elem1111"]=> + object(SimpleXMLElement)#%d (0) { + } + } + } +} +===sxe->elem1 +bool(true) +object(SimpleXMLElement)#%d (3) { + ["@attributes"]=> + array(2) { + ["attr1"]=> + string(5) "first" + ["attr2"]=> + string(6) "second" + } + ["comment"]=> + object(SimpleXMLElement)#%d (0) { + } + ["elem2"]=> + object(SimpleXMLElement)#%d (2) { + ["@attributes"]=> + array(2) { + ["att25"]=> + string(2) "25" + ["att42"]=> + string(2) "42" + } + ["elem3"]=> + object(SimpleXMLElement)#%d (1) { + ["elem4"]=> + object(SimpleXMLElement)#%d (1) { + ["test"]=> + object(SimpleXMLElement)#%d (0) { + } + } + } + } +} +===sxe->elem1[0] +bool(true) +object(SimpleXMLElement)#%d (3) { + ["@attributes"]=> + array(2) { + ["attr1"]=> + string(5) "first" + ["attr2"]=> + string(6) "second" + } + ["comment"]=> + object(SimpleXMLElement)#%d (0) { + } + ["elem2"]=> + object(SimpleXMLElement)#%d (2) { + ["@attributes"]=> + array(2) { + ["att25"]=> + string(2) "25" + ["att42"]=> + string(2) "42" + } + ["elem3"]=> + object(SimpleXMLElement)#%d (1) { + ["elem4"]=> + object(SimpleXMLElement)#%d (1) { + ["test"]=> + object(SimpleXMLElement)#%d (0) { + } + } + } + } +} +===sxe->elem1[0]->elem2 +bool(true) +object(SimpleXMLElement)#%d (2) { + ["@attributes"]=> + array(2) { + ["att25"]=> + string(2) "25" + ["att42"]=> + string(2) "42" + } + ["elem3"]=> + object(SimpleXMLElement)#%d (1) { + ["elem4"]=> + object(SimpleXMLElement)#%d (1) { + ["test"]=> + object(SimpleXMLElement)#%d (0) { + } + } + } +} +===sxe->elem1[0]->elem2->bla +bool(false) +object(SimpleXMLElement)#%d (0) { +} +===sxe->elem1[0]["attr1"] +bool(true) +object(SimpleXMLElement)#%d (1) { + [0]=> + string(5) "first" +} +===sxe->elem1[0]->attr1 +bool(false) +object(SimpleXMLElement)#%d (0) { +} +===sxe->elem1[1] +bool(true) +object(SimpleXMLElement)#%d (1) { + ["@attributes"]=> + array(2) { + ["attr1"]=> + string(2) "11" + ["attr2"]=> + string(2) "12" + } +} +===sxe->elem1[2] +bool(false) +NULL +===sxe->elem11 +bool(true) +object(SimpleXMLElement)#%d (1) { + ["elem111"]=> + object(SimpleXMLElement)#%d (1) { + ["elem1111"]=> + object(SimpleXMLElement)#%d (0) { + } + } +} +===sxe->elem11->elem111 +bool(true) +object(SimpleXMLElement)#%d (1) { + ["elem1111"]=> + object(SimpleXMLElement)#%d (0) { + } +} +===sxe->elem11->elem111->elem1111 +bool(true) +object(SimpleXMLElement)#%d (0) { +} +===sxe->elem22 +bool(false) +object(SimpleXMLElement)#%d (0) { +} +===sxe->elem22->elem222 +bool(false) +NULL +===sxe->elem22->attr22 +bool(false) +NULL +===sxe->elem22["attr22"] +bool(false) +NULL +===DONE=== diff --git a/ext/simplexml/tests/000.xml b/ext/simplexml/tests/000.xml new file mode 100755 index 0000000000..b0f2785463 --- /dev/null +++ b/ext/simplexml/tests/000.xml @@ -0,0 +1,16 @@ + + +%incent; +]> + + There is some text. + + + + + + Here is some more + + + \ No newline at end of file diff --git a/ext/simplexml/tests/001.phpt b/ext/simplexml/tests/001.phpt index cacc2d3066..0be77710e5 100644 --- a/ext/simplexml/tests/001.phpt +++ b/ext/simplexml/tests/001.phpt @@ -5,39 +5,39 @@ SimpleXML: Simple document --FILE-- ---EXPECT-- -SimpleXMLElement Object -( - [elem1] => SimpleXMLElement Object - ( - [comment] => SimpleXMLElement Object - ( - ) - - [elem2] => SimpleXMLElement Object - ( - [elem3] => SimpleXMLElement Object - ( - [elem4] => SimpleXMLElement Object - ( - [test] => SimpleXMLElement Object - ( - ) - - ) - - ) - - ) - - ) - -) ----Done--- +===DONE=== +--EXPECTF-- +object(SimpleXMLElement)#%d (2) { + ["@attributes"]=> + array(1) { + ["id"]=> + string(5) "elem1" + } + ["elem1"]=> + object(SimpleXMLElement)#%d (3) { + ["@attributes"]=> + array(1) { + ["attr1"]=> + string(5) "first" + } + ["comment"]=> + object(SimpleXMLElement)#%d (0) { + } + ["elem2"]=> + object(SimpleXMLElement)#%d (1) { + ["elem3"]=> + object(SimpleXMLElement)#%d (1) { + ["elem4"]=> + object(SimpleXMLElement)#%d (1) { + ["test"]=> + object(SimpleXMLElement)#%d (0) { + } + } + } + } + } +} +===DONE=== diff --git a/ext/simplexml/tests/002.phpt b/ext/simplexml/tests/002.phpt index 95d644fe71..4f1f6b6224 100644 --- a/ext/simplexml/tests/002.phpt +++ b/ext/simplexml/tests/002.phpt @@ -1,5 +1,5 @@ --TEST-- -SimpleXML and clone +SimpleXML: clone --SKIPIF-- --FILE-- @@ -26,37 +26,39 @@ $sxe = simplexml_load_string($xml); $copy = clone $sxe; -print_r($copy); - -echo "---Done---\n"; +var_dump($copy); ?> ---EXPECT-- -SimpleXMLElement Object -( - [elem1] => SimpleXMLElement Object - ( - [comment] => SimpleXMLElement Object - ( - ) - - [elem2] => SimpleXMLElement Object - ( - [elem3] => SimpleXMLElement Object - ( - [elem4] => SimpleXMLElement Object - ( - [test] => SimpleXMLElement Object - ( - ) - - ) - - ) - - ) - - ) - -) ----Done--- +===DONE=== +--EXPECTF-- +object(SimpleXMLElement)#%d (2) { + ["@attributes"]=> + array(1) { + ["id"]=> + string(5) "elem1" + } + ["elem1"]=> + object(SimpleXMLElement)#%d (3) { + ["@attributes"]=> + array(1) { + ["attr1"]=> + string(5) "first" + } + ["comment"]=> + object(SimpleXMLElement)#%d (0) { + } + ["elem2"]=> + object(SimpleXMLElement)#%d (1) { + ["elem3"]=> + object(SimpleXMLElement)#%d (1) { + ["elem4"]=> + object(SimpleXMLElement)#%d (1) { + ["test"]=> + object(SimpleXMLElement)#%d (0) { + } + } + } + } + } +} +===DONE=== diff --git a/ext/simplexml/tests/003.phpt b/ext/simplexml/tests/003.phpt index 96aad372da..105f616d60 100755 --- a/ext/simplexml/tests/003.phpt +++ b/ext/simplexml/tests/003.phpt @@ -1,5 +1,5 @@ --TEST-- -SimpleXML and Entities +SimpleXML: Entities --SKIPIF-- --FILE-- @@ -26,44 +26,44 @@ $xml =<< EOF; -$sxe = simplexml_load_string($xml); - -print_r($sxe); - -echo "---Done---\n"; +var_dump(simplexml_load_string($xml)); ?> ---EXPECT-- -SimpleXMLElement Object -( - [elem1] => SimpleXMLElement Object - ( - [comment] => SimpleXMLElement Object - ( - ) - - [elem2] => SimpleXMLElement Object - ( - [elem3] => SimpleXMLElement Object - ( - [included-entity] => SimpleXMLElement Object - ( - [included-entity] => This is text included from an entity - ) - - [elem4] => SimpleXMLElement Object - ( - [test] => SimpleXMLElement Object - ( - ) - - ) - - ) - - ) - - ) - -) ----Done--- +===DONE=== +--EXPECTF-- +object(SimpleXMLElement)#%d (2) { + ["@attributes"]=> + array(1) { + ["id"]=> + string(5) "elem1" + } + ["elem1"]=> + object(SimpleXMLElement)#%d (3) { + ["@attributes"]=> + array(1) { + ["attr1"]=> + string(5) "first" + } + ["comment"]=> + object(SimpleXMLElement)#%d (0) { + } + ["elem2"]=> + object(SimpleXMLElement)#%d (1) { + ["elem3"]=> + object(SimpleXMLElement)#%d (2) { + ["included-entity"]=> + object(SimpleXMLElement)#%d (1) { + ["included-entity"]=> + string(36) "This is text included from an entity" + } + ["elem4"]=> + object(SimpleXMLElement)#%d (1) { + ["test"]=> + object(SimpleXMLElement)#%d (0) { + } + } + } + } + } +} +===DONE=== diff --git a/ext/simplexml/tests/004.phpt b/ext/simplexml/tests/004.phpt index 82a0d68980..21cb5469e0 100755 --- a/ext/simplexml/tests/004.phpt +++ b/ext/simplexml/tests/004.phpt @@ -1,5 +1,5 @@ --TEST-- -SimpleXML and CDATA +SimpleXML: CDATA --SKIPIF-- --FILE-- @@ -25,7 +25,7 @@ $sxe = simplexml_load_string(<<elem1; $elem2 = $elem1->elem2; @@ -33,63 +33,36 @@ var_dump(trim((string)$elem2)); ?> ===DONE=== ---EXPECT-- -SimpleXMLElement Object -( - [elem1] => SimpleXMLElement Object - ( - [comment] => SimpleXMLElement Object - ( - ) - - [elem2] => SimpleXMLElement Object - ( - [elem3] => SimpleXMLElement Object - ( - [elem4] => SimpleXMLElement Object - ( - [test] => SimpleXMLElement Object - ( - ) - - ) - - ) - - ) - - ) - -) +--EXPECTF-- +object(SimpleXMLElement)#%d (2) { + ["@attributes"]=> + array(1) { + ["id"]=> + string(5) "elem1" + } + ["elem1"]=> + object(SimpleXMLElement)#%d (3) { + ["@attributes"]=> + array(1) { + ["attr1"]=> + string(5) "first" + } + ["comment"]=> + object(SimpleXMLElement)#%d (0) { + } + ["elem2"]=> + object(SimpleXMLElement)#%d (1) { + ["elem3"]=> + object(SimpleXMLElement)#%d (1) { + ["elem4"]=> + object(SimpleXMLElement)#%d (1) { + ["test"]=> + object(SimpleXMLElement)#%d (0) { + } + } + } + } + } +} string(11) "CDATA block" ===DONE=== ---UEXPECT-- -SimpleXMLElement Object -( - [elem1] => SimpleXMLElement Object - ( - [comment] => SimpleXMLElement Object - ( - ) - - [elem2] => SimpleXMLElement Object - ( - [elem3] => SimpleXMLElement Object - ( - [elem4] => SimpleXMLElement Object - ( - [test] => SimpleXMLElement Object - ( - ) - - ) - - ) - - ) - - ) - -) -unicode(11) "CDATA block" -===DONE=== diff --git a/ext/simplexml/tests/005.phpt b/ext/simplexml/tests/005.phpt index a2c3756f3e..fc24b903ac 100755 --- a/ext/simplexml/tests/005.phpt +++ b/ext/simplexml/tests/005.phpt @@ -1,5 +1,5 @@ --TEST-- -SimpleXML and text data +SimpleXML: Text data --SKIPIF-- --FILE-- diff --git a/ext/simplexml/tests/006.phpt b/ext/simplexml/tests/006.phpt index 5b44c18a31..954452ab8e 100755 --- a/ext/simplexml/tests/006.phpt +++ b/ext/simplexml/tests/006.phpt @@ -1,5 +1,5 @@ --TEST-- -SimpleXML and foreach +SimpleXML: foreach --SKIPIF-- --FILE-- diff --git a/ext/simplexml/tests/007.phpt b/ext/simplexml/tests/007.phpt index 754ecf6f55..51d7a847f7 100755 --- a/ext/simplexml/tests/007.phpt +++ b/ext/simplexml/tests/007.phpt @@ -1,5 +1,5 @@ --TEST-- -SimpleXML and attributes +SimpleXML: Attributes --SKIPIF-- --FILE-- @@ -48,7 +48,12 @@ var_dump($a); ===Done=== --EXPECTF-- ===Property=== -object(SimpleXMLElement)#%d (2) { +object(SimpleXMLElement)#%d (3) { + ["@attributes"]=> + array(1) { + ["attr1"]=> + string(5) "first" + } ["comment"]=> object(SimpleXMLElement)#%d (0) { } @@ -90,47 +95,3 @@ NULL int(4) int(4) ===Done=== ---UEXPECTF-- -===Property=== -object(SimpleXMLElement)#%d (2) { - [u"comment"]=> - object(SimpleXMLElement)#%d (0) { - } - [u"elem2"]=> - object(SimpleXMLElement)#%d (1) { - [u"elem3"]=> - object(SimpleXMLElement)#%d (1) { - [u"elem4"]=> - object(SimpleXMLElement)#%d (1) { - [u"test"]=> - object(SimpleXMLElement)#%d (0) { - } - } - } - } -} -===Array=== -object(SimpleXMLElement)#%d (1) { - [0]=> - unicode(5) "elem1" -} -object(SimpleXMLElement)#%d (1) { - [0]=> - unicode(5) "first" -} -===Set=== -object(SimpleXMLElement)#%d (1) { - [0]=> - unicode(8) "Changed1" -} -object(SimpleXMLElement)#%d (1) { - [0]=> - unicode(2) "12" -} -===Unset=== -NULL -NULL -===Misc.=== -int(4) -int(4) -===Done=== diff --git a/ext/simplexml/tests/008.phpt b/ext/simplexml/tests/008.phpt index 76b6ec8fe8..aaa2759aca 100644 --- a/ext/simplexml/tests/008.phpt +++ b/ext/simplexml/tests/008.phpt @@ -1,5 +1,5 @@ --TEST-- -SimpleXML and XPath +SimpleXML: XPath --SKIPIF-- --FILE-- diff --git a/ext/simplexml/tests/009.phpt b/ext/simplexml/tests/009.phpt index 83f4629ce4..7663f6a92b 100755 --- a/ext/simplexml/tests/009.phpt +++ b/ext/simplexml/tests/009.phpt @@ -1,5 +1,5 @@ --TEST-- -SimpleXML and foreach +SimpleXML: foreach --SKIPIF-- --FILE-- diff --git a/ext/simplexml/tests/010.phpt b/ext/simplexml/tests/010.phpt index ea6c7fd079..267780905b 100644 --- a/ext/simplexml/tests/010.phpt +++ b/ext/simplexml/tests/010.phpt @@ -26,38 +26,39 @@ $xml =<< EOF; -$sxe = simplexml_load_string($xml, 'simplexml_inherited'); - -print_r($sxe); +var_dump(simplexml_load_string($xml, 'simplexml_inherited')); ?> ===DONE=== ---EXPECT-- -simplexml_inherited Object -( - [elem1] => simplexml_inherited Object - ( - [comment] => simplexml_inherited Object - ( - ) - - [elem2] => simplexml_inherited Object - ( - [elem3] => simplexml_inherited Object - ( - [elem4] => simplexml_inherited Object - ( - [test] => simplexml_inherited Object - ( - ) - - ) - - ) - - ) - - ) - -) +--EXPECTF-- +object(simplexml_inherited)#%d (2) { + ["@attributes"]=> + array(1) { + ["id"]=> + string(5) "elem1" + } + ["elem1"]=> + object(simplexml_inherited)#%d (3) { + ["@attributes"]=> + array(1) { + ["attr1"]=> + string(5) "first" + } + ["comment"]=> + object(simplexml_inherited)#%d (0) { + } + ["elem2"]=> + object(simplexml_inherited)#%d (1) { + ["elem3"]=> + object(simplexml_inherited)#%d (1) { + ["elem4"]=> + object(simplexml_inherited)#%d (1) { + ["test"]=> + object(simplexml_inherited)#%d (0) { + } + } + } + } + } +} ===DONE=== diff --git a/ext/simplexml/tests/011.phpt b/ext/simplexml/tests/011.phpt index f48c9f1eec..74ea4705ca 100755 --- a/ext/simplexml/tests/011.phpt +++ b/ext/simplexml/tests/011.phpt @@ -1,5 +1,5 @@ --TEST-- -SimpleXML and echo/print +SimpleXML: echo/print --SKIPIF-- --FILE-- diff --git a/ext/simplexml/tests/020.phpt b/ext/simplexml/tests/020.phpt index a2a328736c..9e91b5ac3a 100755 --- a/ext/simplexml/tests/020.phpt +++ b/ext/simplexml/tests/020.phpt @@ -1,5 +1,5 @@ --TEST-- -SimpleXML attribute compared to string +SimpleXML: Attribute compared to string --SKIPIF-- --FILE-- diff --git a/ext/simplexml/tests/021.phpt b/ext/simplexml/tests/021.phpt index e58e26d6ee..d5138685f5 100644 --- a/ext/simplexml/tests/021.phpt +++ b/ext/simplexml/tests/021.phpt @@ -1,5 +1,5 @@ --TEST-- -SimpleXML element check +SimpleXML: Element check --SKIPIF-- --FILE-- diff --git a/ext/simplexml/tests/022.phpt b/ext/simplexml/tests/022.phpt index 4a646205d5..2af4a1dd28 100755 --- a/ext/simplexml/tests/022.phpt +++ b/ext/simplexml/tests/022.phpt @@ -1,5 +1,5 @@ --TEST-- -SimpleXML and attributes inside foreach +SimpleXML: Attributes inside foreach --SKIPIF-- --FILE-- @@ -12,6 +12,13 @@ EOF; $sxe = simplexml_load_string($xml); +echo "===CONTENT===\n"; +var_dump($sxe->content); + +echo "===FILE===\n"; +var_dump($sxe->content->file); + +echo "===FOREACH===\n"; foreach($sxe->content->file as $file) { var_dump($file); @@ -21,18 +28,35 @@ foreach($sxe->content->file as $file) ?> ===DONE=== --EXPECTF-- -object(SimpleXMLElement)#%d (0) { +===CONTENT=== +object(SimpleXMLElement)#%d (1) { + ["file"]=> + object(SimpleXMLElement)#%d (1) { + ["@attributes"]=> + array(1) { + ["glob"]=> + string(11) "slide_*.xml" + } + } } +===FILE=== object(SimpleXMLElement)#%d (1) { - [0]=> - string(11) "slide_*.xml" + ["@attributes"]=> + array(1) { + ["glob"]=> + string(11) "slide_*.xml" + } } -===DONE=== ---UEXPECTF-- -object(SimpleXMLElement)#%d (0) { +===FOREACH=== +object(SimpleXMLElement)#%d (1) { + ["@attributes"]=> + array(1) { + ["glob"]=> + string(11) "slide_*.xml" + } } object(SimpleXMLElement)#%d (1) { [0]=> - unicode(11) "slide_*.xml" + string(11) "slide_*.xml" } ===DONE=== diff --git a/ext/simplexml/tests/023.phpt b/ext/simplexml/tests/023.phpt index dd6dde59d7..515a1460c9 100755 --- a/ext/simplexml/tests/023.phpt +++ b/ext/simplexml/tests/023.phpt @@ -22,7 +22,12 @@ var_dump($sxe['attr']); ?> ===DONE=== --EXPECTF-- -object(SimpleXMLElement)#%d (0) { +object(SimpleXMLElement)#%d (1) { + ["@attributes"]=> + array(1) { + ["attr"]=> + string(%d) "foo%sbar%sbaz" + } } object(SimpleXMLElement)#%d (1) { [0]=> diff --git a/ext/simplexml/tests/bug27010.phpt b/ext/simplexml/tests/bug27010.phpt index 9ba9f7b6bd..8649eb4fe6 100755 --- a/ext/simplexml/tests/bug27010.phpt +++ b/ext/simplexml/tests/bug27010.phpt @@ -1,5 +1,5 @@ --TEST-- -#27010: segfault and node text not displayed when returned from children() +Bug #27010: segfault and node text not displayed when returned from children() --FILE-- '); -echo $root->children('reserved-ns')->child; -echo "\n"; -echo $root->children('special-ns')->child; -foreach ($root->child as $child) { - echo "$child\n"; -} -echo "\n---Done---\n"; +var_dump($root->children('reserved-ns')->child); +var_dump($root->children('special-ns')->child); +var_dump((string)$root->children('reserved-ns')->child); +var_dump((string)$root->children('special-ns')->child); +var_dump($root->child); ?> ---EXPECT-- -Hello -World ----Done--- +===DONE=== +--EXPECTF-- +object(SimpleXMLElement)#%d (1) { + [0]=> + string(5) "Hello" +} +object(SimpleXMLElement)#%d (1) { + [0]=> + string(5) "World" +} +string(5) "Hello" +string(5) "World" +object(SimpleXMLElement)#%d (0) { +} +===DONE=== diff --git a/ext/simplexml/tests/simplexml_import_dom.phpt b/ext/simplexml/tests/simplexml_import_dom.phpt index c66ba8f087..76e7f041dd 100755 --- a/ext/simplexml/tests/simplexml_import_dom.phpt +++ b/ext/simplexml/tests/simplexml_import_dom.phpt @@ -1,5 +1,5 @@ --TEST-- -Interop: simplexml_import_dom +SimpleXML [interop]: simplexml_import_dom --SKIPIF-- diff --git a/ext/simplexml/tests/sxe.dtd b/ext/simplexml/tests/sxe.dtd index 8a8dde4308..b75a7922b0 100755 --- a/ext/simplexml/tests/sxe.dtd +++ b/ext/simplexml/tests/sxe.dtd @@ -1,21 +1,34 @@ - + - + - - + + - + - + + + + + + + + + + + + +