colder Thu Nov 6 00:37:13 2008 UTC Added files: (Branch: PHP_5_3) /php-src/ext/simplexml sxe.c sxe.h /php-src/ext/simplexml/tests bug42259.phpt sxe_001.phpt sxe_002.phpt sxe_003.phpt sxe_004.phpt sxe_005.phpt
Removed files: /php-src/ext/spl spl_sxe.c spl_sxe.h /php-src/ext/spl/tests bug42259.phpt sxe_001.phpt sxe_002.phpt sxe_003.phpt sxe_004.phpt sxe_005.phpt Modified files: /php-src/ext/spl config.m4 config.w32 package.xml php_spl.c /php-src/ext/simplexml config.m4 config.w32 simplexml.c Log: MFH: Fix #45976 (Move SXE from SPL to SimpleXML)
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/config.m4?r1=1.13.2.4.2.3.2.5&r2=1.13.2.4.2.3.2.6&diff_format=u Index: php-src/ext/spl/config.m4 diff -u php-src/ext/spl/config.m4:1.13.2.4.2.3.2.5 php-src/ext/spl/config.m4:1.13.2.4.2.3.2.6 --- php-src/ext/spl/config.m4:1.13.2.4.2.3.2.5 Wed Jun 18 14:54:39 2008 +++ php-src/ext/spl/config.m4 Thu Nov 6 00:37:12 2008 @@ -1,4 +1,4 @@ -dnl $Id: config.m4,v 1.13.2.4.2.3.2.5 2008/06/18 14:54:39 colder Exp $ +dnl $Id: config.m4,v 1.13.2.4.2.3.2.6 2008/11/06 00:37:12 colder Exp $ dnl config.m4 for extension SPL AC_MSG_CHECKING(whether zend_object_value is packed) @@ -22,6 +22,6 @@ CPPFLAGS=$old_CPPFLAGS AC_DEFINE_UNQUOTED(HAVE_PACKED_OBJECT_VALUE, $ac_result, [Whether struct _zend_object_value is packed]) AC_DEFINE(HAVE_SPL, 1, [Whether you want SPL (Standard PHP Library) support]) - PHP_NEW_EXTENSION(spl, php_spl.c spl_functions.c spl_engine.c spl_iterators.c spl_array.c spl_directory.c spl_sxe.c spl_exceptions.c spl_observer.c spl_dllist.c spl_heap.c spl_fixedarray.c, no) - PHP_INSTALL_HEADERS([ext/spl], [php_spl.h spl_array.h spl_directory.h spl_engine.h spl_exceptions.h spl_functions.h spl_iterators.h spl_observer.h spl_sxe.h spl_dllist.h spl_heap.h spl_fixedarray.h]) + PHP_NEW_EXTENSION(spl, php_spl.c spl_functions.c spl_engine.c spl_iterators.c spl_array.c spl_directory.c spl_exceptions.c spl_observer.c spl_dllist.c spl_heap.c spl_fixedarray.c, no) + PHP_INSTALL_HEADERS([ext/spl], [php_spl.h spl_array.h spl_directory.h spl_engine.h spl_exceptions.h spl_functions.h spl_iterators.h spl_observer.h spl_dllist.h spl_heap.h spl_fixedarray.h]) PHP_ADD_EXTENSION_DEP(spl, pcre, true) http://cvs.php.net/viewvc.cgi/php-src/ext/spl/config.w32?r1=1.7.6.6&r2=1.7.6.7&diff_format=u Index: php-src/ext/spl/config.w32 diff -u php-src/ext/spl/config.w32:1.7.6.6 php-src/ext/spl/config.w32:1.7.6.7 --- php-src/ext/spl/config.w32:1.7.6.6 Mon Jun 23 10:22:42 2008 +++ php-src/ext/spl/config.w32 Thu Nov 6 00:37:12 2008 @@ -1,6 +1,6 @@ -// $Id: config.w32,v 1.7.6.6 2008/06/23 10:22:42 pajoye Exp $ +// $Id: config.w32,v 1.7.6.7 2008/11/06 00:37:12 colder Exp $ // vim:ft=javascript -EXTENSION("spl", "php_spl.c spl_functions.c spl_engine.c spl_iterators.c spl_array.c spl_directory.c spl_sxe.c spl_exceptions.c spl_observer.c spl_dllist.c spl_heap.c spl_fixedarray.c", false /*never shared */); +EXTENSION("spl", "php_spl.c spl_functions.c spl_engine.c spl_iterators.c spl_array.c spl_directory.c spl_exceptions.c spl_observer.c spl_dllist.c spl_heap.c spl_fixedarray.c", false /*never shared */); AC_DEFINE('HAVE_SPL', 1); PHP_SPL="yes"; http://cvs.php.net/viewvc.cgi/php-src/ext/spl/package.xml?r1=1.3&r2=1.3.8.1&diff_format=u Index: php-src/ext/spl/package.xml diff -u php-src/ext/spl/package.xml:1.3 php-src/ext/spl/package.xml:1.3.8.1 --- php-src/ext/spl/package.xml:1.3 Mon Jan 19 08:32:58 2004 +++ php-src/ext/spl/package.xml Thu Nov 6 00:37:12 2008 @@ -34,8 +34,6 @@ <file role="src" name="spl_functions.h"/> <file role="src" name="spl_iterators.c"/> <file role="src" name="spl_iterators.h"/> - <file role="src" name="spl_sxe.c"/> - <file role="src" name="spl_sxe.h"/> <file role="doc" name="CREDITS"/> <file role="doc" name="README"/> <file role="doc" name="TODO"/> http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.c?r1=1.52.2.28.2.17.2.28&r2=1.52.2.28.2.17.2.29&diff_format=u Index: php-src/ext/spl/php_spl.c diff -u php-src/ext/spl/php_spl.c:1.52.2.28.2.17.2.28 php-src/ext/spl/php_spl.c:1.52.2.28.2.17.2.29 --- php-src/ext/spl/php_spl.c:1.52.2.28.2.17.2.28 Sun Nov 2 21:19:36 2008 +++ php-src/ext/spl/php_spl.c Thu Nov 6 00:37:12 2008 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_spl.c,v 1.52.2.28.2.17.2.28 2008/11/02 21:19:36 felipe Exp $ */ +/* $Id: php_spl.c,v 1.52.2.28.2.17.2.29 2008/11/06 00:37:12 colder Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -32,7 +32,6 @@ #include "spl_array.h" #include "spl_directory.h" #include "spl_iterators.h" -#include "spl_sxe.h" #include "spl_exceptions.h" #include "spl_observer.h" #include "spl_dllist.h" @@ -191,7 +190,6 @@ SPL_ADD_CLASS(RegexIterator, z_list, sub, allow, ce_flags); \ SPL_ADD_CLASS(RuntimeException, z_list, sub, allow, ce_flags); \ SPL_ADD_CLASS(SeekableIterator, z_list, sub, allow, ce_flags); \ - SPL_ADD_CLASS(SimpleXMLIterator, z_list, sub, allow, ce_flags); \ SPL_ADD_CLASS(SplDoublyLinkedList, z_list, sub, allow, ce_flags); \ SPL_ADD_CLASS(SplFileInfo, z_list, sub, allow, ce_flags); \ SPL_ADD_CLASS(SplFileObject, z_list, sub, allow, ce_flags); \ @@ -844,7 +842,6 @@ PHP_MINIT(spl_iterators)(INIT_FUNC_ARGS_PASSTHRU); PHP_MINIT(spl_array)(INIT_FUNC_ARGS_PASSTHRU); PHP_MINIT(spl_directory)(INIT_FUNC_ARGS_PASSTHRU); - PHP_MINIT(spl_sxe)(INIT_FUNC_ARGS_PASSTHRU); PHP_MINIT(spl_dllist)(INIT_FUNC_ARGS_PASSTHRU); PHP_MINIT(spl_heap)(INIT_FUNC_ARGS_PASSTHRU); PHP_MINIT(spl_fixedarray)(INIT_FUNC_ARGS_PASSTHRU); @@ -877,23 +874,10 @@ return SUCCESS; } /* }}} */ -#ifdef HAVE_SIMPLEXML -static const zend_module_dep spl_deps[] = { - ZEND_MOD_REQUIRED("libxml") - ZEND_MOD_REQUIRED("simplexml") - {NULL, NULL, NULL} -}; -#endif - /* {{{ spl_module_entry */ zend_module_entry spl_module_entry = { -#ifdef HAVE_SIMPLEXML - STANDARD_MODULE_HEADER_EX, NULL, - spl_deps, -#else STANDARD_MODULE_HEADER, -#endif "SPL", spl_functions, PHP_MINIT(spl), http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/config.m4?r1=1.9.2.1&r2=1.9.2.1.4.1&diff_format=u Index: php-src/ext/simplexml/config.m4 diff -u php-src/ext/simplexml/config.m4:1.9.2.1 php-src/ext/simplexml/config.m4:1.9.2.1.4.1 --- php-src/ext/simplexml/config.m4:1.9.2.1 Sat Oct 1 15:41:37 2005 +++ php-src/ext/simplexml/config.m4 Thu Nov 6 00:37:13 2008 @@ -1,4 +1,4 @@ -dnl $Id: config.m4,v 1.9.2.1 2005/10/01 15:41:37 helly Exp $ +dnl $Id: config.m4,v 1.9.2.1.4.1 2008/11/06 00:37:13 colder Exp $ dnl config.m4 for extension simplexml PHP_ARG_ENABLE(simplexml, whether to enable SimpleXML support, @@ -17,7 +17,7 @@ PHP_SETUP_LIBXML(SIMPLEXML_SHARED_LIBADD, [ AC_DEFINE(HAVE_SIMPLEXML,1,[ ]) - PHP_NEW_EXTENSION(simplexml, simplexml.c, $ext_shared) + PHP_NEW_EXTENSION(simplexml, simplexml.c sxe.c, $ext_shared) PHP_SUBST(SIMPLEXML_SHARED_LIBADD) ], [ AC_MSG_ERROR([xml2-config not found. Please check your libxml2 installation.]) http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/config.w32?r1=1.4.8.1&r2=1.4.8.2&diff_format=u Index: php-src/ext/simplexml/config.w32 diff -u php-src/ext/simplexml/config.w32:1.4.8.1 php-src/ext/simplexml/config.w32:1.4.8.2 --- php-src/ext/simplexml/config.w32:1.4.8.1 Mon Jun 23 18:40:29 2008 +++ php-src/ext/simplexml/config.w32 Thu Nov 6 00:37:13 2008 @@ -1,11 +1,11 @@ -// $Id: config.w32,v 1.4.8.1 2008/06/23 18:40:29 pajoye Exp $ +// $Id: config.w32,v 1.4.8.2 2008/11/06 00:37:13 colder Exp $ // vim:ft=javascript ARG_WITH("simplexml", "Simple XML support", "yes"); if (PHP_SIMPLEXML == "yes" && PHP_LIBXML == "yes" && ADD_EXTENSION_DEP('simplexml', 'libxml')) { - EXTENSION("simplexml", "simplexml.c"); + EXTENSION("simplexml", "simplexml.c sxe.c"); AC_DEFINE("HAVE_SIMPLEXML", 1, "Simple XML support"); if (!PHP_SIMPLEXML_SHARED) { ADD_FLAG("CFLAGS_SIMPLEXML", "/D LIBXML_STATIC"); http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.151.2.22.2.35.2.25&r2=1.151.2.22.2.35.2.26&diff_format=u Index: php-src/ext/simplexml/simplexml.c diff -u php-src/ext/simplexml/simplexml.c:1.151.2.22.2.35.2.25 php-src/ext/simplexml/simplexml.c:1.151.2.22.2.35.2.26 --- php-src/ext/simplexml/simplexml.c:1.151.2.22.2.35.2.25 Sun Nov 2 21:19:36 2008 +++ php-src/ext/simplexml/simplexml.c Thu Nov 6 00:37:13 2008 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: simplexml.c,v 1.151.2.22.2.35.2.25 2008/11/02 21:19:36 felipe Exp $ */ +/* $Id: simplexml.c,v 1.151.2.22.2.35.2.26 2008/11/06 00:37:13 colder Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -34,9 +34,7 @@ #include "php_simplexml_exports.h" #include "zend_exceptions.h" #include "zend_interfaces.h" -#ifdef HAVE_SPL -#include "ext/spl/spl_sxe.h" -#endif +#include "sxe.h" #define SXE_ELEMENT_BY_NAME 0 @@ -2535,14 +2533,11 @@ sxe_object_handlers.get_class_entry = zend_get_std_object_handlers()->get_class_entry; sxe_object_handlers.get_class_name = zend_get_std_object_handlers()->get_class_name; -#ifdef HAVE_SPL - if (zend_get_module_started("spl") == SUCCESS) { - PHP_MINIT(spl_sxe)(INIT_FUNC_ARGS_PASSTHRU); - } -#endif /* HAVE_SPL */ php_libxml_register_export(sxe_class_entry, simplexml_export_node); + PHP_MINIT(sxe)(INIT_FUNC_ARGS_PASSTHRU); + return SUCCESS; } /* }}} */ @@ -2562,7 +2557,7 @@ { php_info_print_table_start(); php_info_print_table_header(2, "Simplexml support", "enabled"); - php_info_print_table_row(2, "Revision", "$Revision: 1.151.2.22.2.35.2.25 $"); + php_info_print_table_row(2, "Revision", "$Revision: 1.151.2.22.2.35.2.26 $"); php_info_print_table_row(2, "Schema support", #ifdef LIBXML_SCHEMAS_ENABLED "enabled"); http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/sxe.c?view=markup&rev=1.1 Index: php-src/ext/simplexml/sxe.c +++ php-src/ext/simplexml/sxe.c /* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2008 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | [EMAIL PROTECTED] so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Marcus Boerger <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ /* $Id: sxe.c,v 1.1 2008/11/06 00:36:28 colder Exp $ */ #ifdef HAVE_CONFIG_H # include "config.h" #endif #include "php.h" #include "php_ini.h" #include "ext/standard/info.h" #include "zend_interfaces.h" #include "ext/spl/php_spl.h" #include "ext/spl/spl_iterators.h" #include "sxe.h" zend_class_entry *ce_SimpleXMLIterator = NULL; zend_class_entry *ce_SimpleXMLElement; #include "php_simplexml_exports.h" /* {{{ proto void SimpleXMLIterator::rewind() U Rewind to first element */ PHP_METHOD(ce_SimpleXMLIterator, rewind) { php_sxe_iterator iter; iter.sxe = php_sxe_fetch_object(getThis() TSRMLS_CC); ce_SimpleXMLElement->iterator_funcs.funcs->rewind((zend_object_iterator*)&iter TSRMLS_CC); } /* }}} */ /* {{{ proto bool SimpleXMLIterator::valid() U Check whether iteration is valid */ PHP_METHOD(ce_SimpleXMLIterator, valid) { php_sxe_object *sxe = php_sxe_fetch_object(getThis() TSRMLS_CC); RETURN_BOOL(sxe->iter.data); } /* }}} */ /* {{{ proto SimpleXMLIterator SimpleXMLIterator::current() U Get current element */ PHP_METHOD(ce_SimpleXMLIterator, current) { php_sxe_object *sxe = php_sxe_fetch_object(getThis() TSRMLS_CC); if (!sxe->iter.data) { return; /* return NULL */ } RETURN_ZVAL(sxe->iter.data, 1, 0); } /* }}} */ /* {{{ proto string SimpleXMLIterator::key() U Get name of current child element */ PHP_METHOD(ce_SimpleXMLIterator, key) { xmlNodePtr curnode; php_sxe_object *intern; php_sxe_object *sxe = php_sxe_fetch_object(getThis() TSRMLS_CC); if (!sxe->iter.data) { RETURN_FALSE; } intern = (php_sxe_object *)zend_object_store_get_object(sxe->iter.data TSRMLS_CC); if (intern != NULL && intern->node != NULL) { curnode = (xmlNodePtr)((php_libxml_node_ptr *)intern->node)->node; RETURN_U_STRINGL(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), (char*)curnode->name, xmlStrlen(curnode->name), 1); } RETURN_FALSE; } /* }}} */ /* {{{ proto void SimpleXMLIterator::next() U Move to next element */ PHP_METHOD(ce_SimpleXMLIterator, next) { php_sxe_iterator iter; iter.sxe = php_sxe_fetch_object(getThis() TSRMLS_CC); ce_SimpleXMLElement->iterator_funcs.funcs->move_forward((zend_object_iterator*)&iter TSRMLS_CC); } /* }}} */ /* {{{ proto bool SimpleXMLIterator::hasChildren() U Check whether element has children (elements) */ PHP_METHOD(ce_SimpleXMLIterator, hasChildren) { php_sxe_object *sxe = php_sxe_fetch_object(getThis() TSRMLS_CC); php_sxe_object *child; xmlNodePtr node; if (!sxe->iter.data || sxe->iter.type == SXE_ITER_ATTRLIST) { RETURN_FALSE; } child = php_sxe_fetch_object(sxe->iter.data TSRMLS_CC); GET_NODE(child, node); if (node) { node = node->children; } while (node && node->type != XML_ELEMENT_NODE) { node = node->next; } RETURN_BOOL(node ? 1 : 0); } /* }}} */ /* {{{ proto SimpleXMLIterator SimpleXMLIterator::getChildren() U Get child element iterator */ PHP_METHOD(ce_SimpleXMLIterator, getChildren) { php_sxe_object *sxe = php_sxe_fetch_object(getThis() TSRMLS_CC); if (!sxe->iter.data || sxe->iter.type == SXE_ITER_ATTRLIST) { return; /* return NULL */ } RETURN_ZVAL(sxe->iter.data, 1, 0); } static const zend_function_entry funcs_SimpleXMLIterator[] = { PHP_ME(ce_SimpleXMLIterator, rewind, NULL, ZEND_ACC_PUBLIC) PHP_ME(ce_SimpleXMLIterator, valid, NULL, ZEND_ACC_PUBLIC) PHP_ME(ce_SimpleXMLIterator, current, NULL, ZEND_ACC_PUBLIC) PHP_ME(ce_SimpleXMLIterator, key, NULL, ZEND_ACC_PUBLIC) PHP_ME(ce_SimpleXMLIterator, next, NULL, ZEND_ACC_PUBLIC) PHP_ME(ce_SimpleXMLIterator, hasChildren, NULL, ZEND_ACC_PUBLIC) PHP_ME(ce_SimpleXMLIterator, getChildren, NULL, ZEND_ACC_PUBLIC) {NULL, NULL, NULL} }; /* }}} */ PHP_MINIT_FUNCTION(sxe) /* {{{ */ { zend_class_entry **pce; zend_class_entry sxi; if (zend_hash_find(CG(class_table), "simplexmlelement", sizeof("SimpleXMLElement"), (void **) &pce) == FAILURE) { ce_SimpleXMLElement = NULL; ce_SimpleXMLIterator = NULL; return SUCCESS; /* SimpleXML must be initialized before */ } ce_SimpleXMLElement = *pce; INIT_CLASS_ENTRY_EX(sxi, "SimpleXMLIterator", strlen("SimpleXMLIterator"), funcs_SimpleXMLIterator); ce_SimpleXMLIterator = zend_register_internal_class_ex(&sxi, ce_SimpleXMLElement, NULL TSRMLS_CC); ce_SimpleXMLIterator->create_object = ce_SimpleXMLElement->create_object; zend_class_implements(ce_SimpleXMLIterator TSRMLS_CC, 1, spl_ce_RecursiveIterator); zend_class_implements(ce_SimpleXMLIterator TSRMLS_CC, 1, spl_ce_Countable); return SUCCESS; } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/sxe.h?view=markup&rev=1.1 Index: php-src/ext/simplexml/sxe.h +++ php-src/ext/simplexml/sxe.h /* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2008 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | [EMAIL PROTECTED] so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Marcus Boerger <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ /* $Id: sxe.h,v 1.1 2008/11/06 00:36:28 colder Exp $ */ #ifndef SXE_H #define SXE_H #include "php.h" extern zend_class_entry *ce_SimpleXMLIterator; PHP_MINIT_FUNCTION(sxe); #endif /* SXE_H */ /* * Local Variables: * c-basic-offset: 4 * tab-width: 4 * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/tests/bug42259.phpt?view=markup&rev=1.1 Index: php-src/ext/simplexml/tests/bug42259.phpt +++ php-src/ext/simplexml/tests/bug42259.phpt --TEST-- Bug #42259 (SimpleXMLIterator loses ancestry) --SKIPIF-- <?php if (!extension_loaded('simplexml')) print 'skip'; if (!extension_loaded("libxml")) print "skip LibXML not present"; ?> --FILE-- <?php $xml =<<<EOF <xml> <fieldset1> <field1/> <field2/> </fieldset1> <fieldset2> <options> <option1/> <option2/> <option3/> </options> <field1/> <field2/> </fieldset2> </xml> EOF; $sxe = new SimpleXMLIterator($xml); $rit = new RecursiveIteratorIterator($sxe, RecursiveIteratorIterator::LEAVES_ONLY); foreach ($rit as $child) { $path = ''; $ancestry = $child->xpath('ancestor-or-self::*'); foreach ($ancestry as $ancestor) { $path .= $ancestor->getName() . '/'; } $path = substr($path, 0, strlen($path) - 1); echo count($ancestry) . ' steps: ' . $path . PHP_EOL; } ?> ===DONE=== --EXPECT-- 3 steps: xml/fieldset1/field1 3 steps: xml/fieldset1/field2 4 steps: xml/fieldset2/options/option1 4 steps: xml/fieldset2/options/option2 4 steps: xml/fieldset2/options/option3 3 steps: xml/fieldset2/field1 3 steps: xml/fieldset2/field2 ===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/tests/sxe_001.phpt?view=markup&rev=1.1 Index: php-src/ext/simplexml/tests/sxe_001.phpt +++ php-src/ext/simplexml/tests/sxe_001.phpt --TEST-- SPL: SimpleXMLIterator --SKIPIF-- <?php if (!extension_loaded("simplexml")) print "skip SimpleXML not present"; if (!extension_loaded("libxml")) print "skip LibXML not present"; ?> --FILE-- <?php $xml =<<<EOF <?xml version='1.0'?> <!DOCTYPE sxe SYSTEM "notfound.dtd"> <sxe id="elem1"> <elem1 attr1='first'> <!-- comment --> <elem2> <elem3> <elem4> <?test processing instruction ?> </elem4> </elem3> </elem2> </elem1> </sxe> EOF; var_dump(simplexml_load_string((binary)$xml, 'SimpleXMLIterator')); ?> ===DONE=== --EXPECTF-- object(SimpleXMLIterator)#%d (2) { [u"@attributes"]=> array(1) { [u"id"]=> unicode(5) "elem1" } [u"elem1"]=> object(SimpleXMLIterator)#%d (3) { [u"@attributes"]=> array(1) { [u"attr1"]=> unicode(5) "first" } [u"comment"]=> object(SimpleXMLIterator)#%d (0) { } [u"elem2"]=> object(SimpleXMLIterator)#%d (1) { [u"elem3"]=> object(SimpleXMLIterator)#%d (1) { [u"elem4"]=> object(SimpleXMLIterator)#%d (1) { [u"test"]=> object(SimpleXMLIterator)#%d (0) { } } } } } } ===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/tests/sxe_002.phpt?view=markup&rev=1.1 Index: php-src/ext/simplexml/tests/sxe_002.phpt +++ php-src/ext/simplexml/tests/sxe_002.phpt --TEST-- SPL: SimpleXMLIterator and recursion --SKIPIF-- <?php if (!extension_loaded('simplexml')) print 'skip'; if (!extension_loaded("libxml")) print "skip LibXML not present"; ?> --FILE-- <?php $xml =<<<EOF <?xml version='1.0'?> <!DOCTYPE sxe SYSTEM "notfound.dtd"> <sxe id="elem1"> Plain text. <elem1 attr1='first'> Bla bla 1. <!-- comment --> <elem2> Here we have some text data. <elem3> And here some more. <elem4> Wow once again. </elem4> </elem3> </elem2> </elem1> <elem11 attr2='second'> Bla bla 2. <elem111> Foo Bar </elem111> </elem11> </sxe> EOF; $sxe = simplexml_load_string((binary)$xml, 'SimpleXMLIterator'); foreach(new RecursiveIteratorIterator($sxe, 1) as $name => $data) { var_dump($name); var_dump(get_class($data)); var_dump(trim($data)); } echo "===DUMP===\n"; var_dump(get_class($sxe)); var_dump(trim($sxe->elem1)); ?> ===DONE=== --EXPECT-- unicode(5) "elem1" unicode(17) "SimpleXMLIterator" unicode(10) "Bla bla 1." unicode(5) "elem2" unicode(17) "SimpleXMLIterator" unicode(28) "Here we have some text data." unicode(5) "elem3" unicode(17) "SimpleXMLIterator" unicode(19) "And here some more." unicode(5) "elem4" unicode(17) "SimpleXMLIterator" unicode(15) "Wow once again." unicode(6) "elem11" unicode(17) "SimpleXMLIterator" unicode(10) "Bla bla 2." unicode(7) "elem111" unicode(17) "SimpleXMLIterator" unicode(7) "Foo Bar" ===DUMP=== unicode(17) "SimpleXMLIterator" unicode(10) "Bla bla 1." ===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/tests/sxe_003.phpt?view=markup&rev=1.1 Index: php-src/ext/simplexml/tests/sxe_003.phpt +++ php-src/ext/simplexml/tests/sxe_003.phpt --TEST-- SPL: SimpleXMLIterator and getChildren() --SKIPIF-- <?php if (!extension_loaded('simplexml')) print 'skip'; if (!extension_loaded("libxml")) print "skip LibXML not present"; ?> --FILE-- <?php $xml =<<<EOF <?xml version='1.0'?> <!DOCTYPE sxe SYSTEM "notfound.dtd"> <sxe id="elem1"> Plain text. <elem1 attr1='first'> Bla bla 1. <!-- comment --> <elem2> Here we have some text data. <elem3> And here some more. <elem4> Wow once again. </elem4> </elem3> </elem2> </elem1> <elem11 attr2='second'> Bla bla 2. <elem111> Foo Bar </elem111> </elem11> </sxe> EOF; $sxe = simplexml_load_string((binary)$xml, 'SimpleXMLIterator'); foreach($sxe->getChildren() as $name => $data) { var_dump($name); var_dump(get_class($data)); var_dump(trim($data)); } echo "===RESET===\n"; for ($sxe->rewind(); $sxe->valid(); $sxe->next()) { var_dump($sxe->hasChildren()); var_dump(trim($sxe->key())); var_dump(trim($sxe->current())); foreach($sxe->getChildren() as $name => $data) { var_dump($name); var_dump(get_class($data)); var_dump(trim($data)); } } ?> ===DONE=== --EXPECTF-- Warning: Invalid argument supplied for foreach() in %ssxe_003.php on line %d ===RESET=== bool(true) unicode(5) "elem1" unicode(10) "Bla bla 1." unicode(5) "elem2" unicode(17) "SimpleXMLIterator" unicode(28) "Here we have some text data." bool(true) unicode(6) "elem11" unicode(10) "Bla bla 2." unicode(7) "elem111" unicode(17) "SimpleXMLIterator" unicode(7) "Foo Bar" ===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/tests/sxe_004.phpt?view=markup&rev=1.1 Index: php-src/ext/simplexml/tests/sxe_004.phpt +++ php-src/ext/simplexml/tests/sxe_004.phpt --TEST-- SPL: SimpleXMLIterator and overridden iterator methods() --SKIPIF-- <?php if (!extension_loaded('simplexml')) print 'skip'; if (!extension_loaded("libxml")) print "skip LibXML not present"; ?> --FILE-- <?php $xml =<<<EOF <?xml version='1.0'?> <!DOCTYPE sxe SYSTEM "notfound.dtd"> <sxe id="elem1"> Plain text. <elem1 attr1='first'> Bla bla 1. <!-- comment --> <elem2> Here we have some text data. <elem3> And here some more. <elem4> Wow once again. </elem4> </elem3> </elem2> </elem1> <elem11 attr2='second'> Bla bla 2. <elem111> Foo Bar </elem111> </elem11> </sxe> EOF; class SXETest extends SimpleXMLIterator { function rewind() { echo __METHOD__ . "\n"; return parent::rewind(); } function valid() { echo __METHOD__ . "\n"; return parent::valid(); } function current() { echo __METHOD__ . "\n"; return parent::current(); } function key() { echo __METHOD__ . "\n"; return parent::key(); } function next() { echo __METHOD__ . "\n"; return parent::next(); } function hasChildren() { echo __METHOD__ . "\n"; return parent::hasChildren(); } function getChildren() { echo __METHOD__ . "\n"; return parent::getChildren(); } } $sxe = new SXETest((binary)$xml); $rit = new RecursiveIteratorIterator($sxe, RecursiveIteratorIterator::SELF_FIRST); foreach($rit as $data) { var_dump(get_class($data)); var_dump(trim($data)); } ?> ===DONE=== --EXPECTF-- SXETest::rewind SXETest::valid SXETest::hasChildren SXETest::valid SXETest::current unicode(7) "SXETest" unicode(10) "Bla bla 1." SXETest::getChildren SXETest::rewind SXETest::valid SXETest::hasChildren SXETest::valid SXETest::current unicode(7) "SXETest" unicode(28) "Here we have some text data." SXETest::getChildren SXETest::rewind SXETest::valid SXETest::hasChildren SXETest::valid SXETest::current unicode(7) "SXETest" unicode(19) "And here some more." SXETest::getChildren SXETest::rewind SXETest::valid SXETest::hasChildren SXETest::valid SXETest::current unicode(7) "SXETest" unicode(15) "Wow once again." SXETest::next SXETest::valid SXETest::next SXETest::valid SXETest::next SXETest::valid SXETest::next SXETest::valid SXETest::hasChildren SXETest::valid SXETest::current unicode(7) "SXETest" unicode(10) "Bla bla 2." SXETest::getChildren SXETest::rewind SXETest::valid SXETest::hasChildren SXETest::valid SXETest::current unicode(7) "SXETest" unicode(7) "Foo Bar" SXETest::next SXETest::valid SXETest::next SXETest::valid SXETest::valid ===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/tests/sxe_005.phpt?view=markup&rev=1.1 Index: php-src/ext/simplexml/tests/sxe_005.phpt +++ php-src/ext/simplexml/tests/sxe_005.phpt --TEST-- SPL: SimpleXMLIterator and overriden count() --SKIPIF-- <?php if (!extension_loaded('simplexml')) print 'skip'; if (!extension_loaded("libxml")) print "skip LibXML not present"; ?> --FILE-- <?php $xml =<<<EOF <?xml version='1.0'?> <sxe> <elem1/> <elem2/> <elem2/> </sxe> EOF; class SXETest extends SimpleXMLIterator { function count() { echo __METHOD__ . "\n"; return parent::count(); } } $sxe = new SXETest((binary)$xml); var_dump(count($sxe)); var_dump(count($sxe->elem1)); var_dump(count($sxe->elem2)); ?> ===DONE=== --EXPECT-- SXETest::count int(3) SXETest::count int(1) SXETest::count int(2) ===DONE===
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php