diff options
| author | Etienne Kneuss <colder@php.net> | 2008-11-06 00:36:29 +0000 |
|---|---|---|
| committer | Etienne Kneuss <colder@php.net> | 2008-11-06 00:36:29 +0000 |
| commit | 6e2845f377461654cca10964c2a0deaf27a2ec80 (patch) | |
| tree | e5ddc4150b1f486309773d8cf9f880ed909cd1a9 /ext/spl | |
| parent | 27357e9ce5dc5e67a8400ea146f2e2b5484e6cd9 (diff) | |
| download | php-git-6e2845f377461654cca10964c2a0deaf27a2ec80.tar.gz | |
Fix #45976 (Move SXE from SPL to SimpleXML)
Diffstat (limited to 'ext/spl')
| -rwxr-xr-x | ext/spl/config.m4 | 4 | ||||
| -rw-r--r-- | ext/spl/config.w32 | 2 | ||||
| -rwxr-xr-x | ext/spl/package.xml | 2 | ||||
| -rwxr-xr-x | ext/spl/php_spl.c | 16 | ||||
| -rwxr-xr-x | ext/spl/spl_sxe.c | 196 | ||||
| -rwxr-xr-x | ext/spl/spl_sxe.h | 40 | ||||
| -rw-r--r-- | ext/spl/tests/bug42259.phpt | 49 | ||||
| -rwxr-xr-x | ext/spl/tests/sxe_001.phpt | 63 | ||||
| -rwxr-xr-x | ext/spl/tests/sxe_002.phpt | 75 | ||||
| -rwxr-xr-x | ext/spl/tests/sxe_003.phpt | 77 | ||||
| -rwxr-xr-x | ext/spl/tests/sxe_004.phpt | 145 | ||||
| -rwxr-xr-x | ext/spl/tests/sxe_005.phpt | 44 |
12 files changed, 3 insertions, 710 deletions
diff --git a/ext/spl/config.m4 b/ext/spl/config.m4 index b8b44f21ab..4ae5f8df4f 100755 --- a/ext/spl/config.m4 +++ b/ext/spl/config.m4 @@ -25,6 +25,6 @@ int main(int argc, char **argv) { PHP_INSTALL_HEADERS([ext/spl/]) 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) diff --git a/ext/spl/config.w32 b/ext/spl/config.w32 index 5cef9cd354..ffa4d57541 100644 --- a/ext/spl/config.w32 +++ b/ext/spl/config.w32 @@ -1,6 +1,6 @@ // $Id$ // 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"; diff --git a/ext/spl/package.xml b/ext/spl/package.xml index f99cd7ce41..372aaecd9f 100755 --- a/ext/spl/package.xml +++ b/ext/spl/package.xml @@ -34,8 +34,6 @@ standard problems. <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"/> diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c index 8d4c1f7935..6d75c4b823 100755 --- a/ext/spl/php_spl.c +++ b/ext/spl/php_spl.c @@ -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" @@ -185,7 +184,6 @@ PHP_FUNCTION(class_implements) 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); \ @@ -864,7 +862,6 @@ PHP_MINIT_FUNCTION(spl) 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); @@ -897,23 +894,10 @@ PHP_RSHUTDOWN_FUNCTION(spl) /* {{{ */ 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), diff --git a/ext/spl/spl_sxe.c b/ext/spl/spl_sxe.c deleted file mode 100755 index 5423431538..0000000000 --- a/ext/spl/spl_sxe.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | 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 | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Marcus Boerger <helly@php.net> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -#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 "php_spl.h" -#include "spl_functions.h" -#include "spl_engine.h" -#include "spl_iterators.h" -#include "spl_sxe.h" -#include "spl_array.h" - -zend_class_entry *spl_ce_SimpleXMLIterator = NULL; -zend_class_entry *spl_ce_SimpleXMLElement; - -#if HAVE_LIBXML && HAVE_SIMPLEXML - -#include "ext/simplexml/php_simplexml_exports.h" - -/* {{{ proto void SimpleXMLIterator::rewind() U - Rewind to first element */ -SPL_METHOD(SimpleXMLIterator, rewind) -{ - php_sxe_iterator iter; - - iter.sxe = php_sxe_fetch_object(getThis() TSRMLS_CC); - spl_ce_SimpleXMLElement->iterator_funcs.funcs->rewind((zend_object_iterator*)&iter TSRMLS_CC); -} -/* }}} */ - -/* {{{ proto bool SimpleXMLIterator::valid() U - Check whether iteration is valid */ -SPL_METHOD(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 */ -SPL_METHOD(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 */ -SPL_METHOD(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 */ -SPL_METHOD(SimpleXMLIterator, next) -{ - php_sxe_iterator iter; - - iter.sxe = php_sxe_fetch_object(getThis() TSRMLS_CC); - spl_ce_SimpleXMLElement->iterator_funcs.funcs->move_forward((zend_object_iterator*)&iter TSRMLS_CC); -} -/* }}} */ - -/* {{{ proto bool SimpleXMLIterator::hasChildren() U - Check whether element has children (elements) */ -SPL_METHOD(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 */ -SPL_METHOD(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 spl_funcs_SimpleXMLIterator[] = { - SPL_ME(SimpleXMLIterator, rewind, NULL, ZEND_ACC_PUBLIC) - SPL_ME(SimpleXMLIterator, valid, NULL, ZEND_ACC_PUBLIC) - SPL_ME(SimpleXMLIterator, current, NULL, ZEND_ACC_PUBLIC) - SPL_ME(SimpleXMLIterator, key, NULL, ZEND_ACC_PUBLIC) - SPL_ME(SimpleXMLIterator, next, NULL, ZEND_ACC_PUBLIC) - SPL_ME(SimpleXMLIterator, hasChildren, NULL, ZEND_ACC_PUBLIC) - SPL_ME(SimpleXMLIterator, getChildren, NULL, ZEND_ACC_PUBLIC) - {NULL, NULL, NULL} -}; -/* }}} */ - -SPL_API PHP_MINIT_FUNCTION(spl_sxe) /* {{{ */ -{ - zend_class_entry **pce; - - if (zend_hash_find(CG(class_table), "simplexmlelement", sizeof("SimpleXMLElement"), (void **) &pce) == FAILURE) { - spl_ce_SimpleXMLElement = NULL; - spl_ce_SimpleXMLIterator = NULL; - return SUCCESS; /* SimpleXML must be initialized before */ - } - - spl_ce_SimpleXMLElement = *pce; - - REGISTER_SPL_SUB_CLASS_EX(SimpleXMLIterator, SimpleXMLElement, spl_ce_SimpleXMLElement->create_object, spl_funcs_SimpleXMLIterator); - REGISTER_SPL_IMPLEMENTS(SimpleXMLIterator, RecursiveIterator); - REGISTER_SPL_IMPLEMENTS(SimpleXMLIterator, Countable); - - return SUCCESS; -} -/* }}} */ - -#else /* HAVE_LIBXML && HAVE_SIMPLEXML */ - -SPL_API PHP_MINIT_FUNCTION(spl_sxe) /* {{{ */ -{ - return SUCCESS; -} - -#endif /* HAVE_LIBXML && HAVE_SIMPLEXML */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: fdm=marker - * vim: noet sw=4 ts=4 - */ diff --git a/ext/spl/spl_sxe.h b/ext/spl/spl_sxe.h deleted file mode 100755 index eca993e4ae..0000000000 --- a/ext/spl/spl_sxe.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | 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 | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Marcus Boerger <helly@php.net> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -#ifndef SPL_SXE_H -#define SPL_SXE_H - -#include "php.h" -#include "php_spl.h" - -extern zend_class_entry *spl_ce_SimpleXMLIterator; - -SPL_API PHP_MINIT_FUNCTION(spl_sxe); - -#endif /* SPL_SXE_H */ - -/* - * Local Variables: - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim600: fdm=marker - * vim: noet sw=4 ts=4 - */ diff --git a/ext/spl/tests/bug42259.phpt b/ext/spl/tests/bug42259.phpt deleted file mode 100644 index 19c02a577a..0000000000 --- a/ext/spl/tests/bug42259.phpt +++ /dev/null @@ -1,49 +0,0 @@ ---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=== diff --git a/ext/spl/tests/sxe_001.phpt b/ext/spl/tests/sxe_001.phpt deleted file mode 100755 index b48621504f..0000000000 --- a/ext/spl/tests/sxe_001.phpt +++ /dev/null @@ -1,63 +0,0 @@ ---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=== diff --git a/ext/spl/tests/sxe_002.phpt b/ext/spl/tests/sxe_002.phpt deleted file mode 100755 index 22e635f962..0000000000 --- a/ext/spl/tests/sxe_002.phpt +++ /dev/null @@ -1,75 +0,0 @@ ---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=== diff --git a/ext/spl/tests/sxe_003.phpt b/ext/spl/tests/sxe_003.phpt deleted file mode 100755 index 78105efb46..0000000000 --- a/ext/spl/tests/sxe_003.phpt +++ /dev/null @@ -1,77 +0,0 @@ ---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=== diff --git a/ext/spl/tests/sxe_004.phpt b/ext/spl/tests/sxe_004.phpt deleted file mode 100755 index 30d4b10a78..0000000000 --- a/ext/spl/tests/sxe_004.phpt +++ /dev/null @@ -1,145 +0,0 @@ ---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=== diff --git a/ext/spl/tests/sxe_005.phpt b/ext/spl/tests/sxe_005.phpt deleted file mode 100755 index 183d351166..0000000000 --- a/ext/spl/tests/sxe_005.phpt +++ /dev/null @@ -1,44 +0,0 @@ ---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=== |
