helly Sun Sep 18 13:15:05 2005 EDT
Added files: (Branch: PHP_5_1)
/php-src/ext/spl/internal recursivearrayiterator.inc
recursivecachingiterator.inc
Removed files:
/php-src/ext/spl/examples recursivearrayiterator.inc
/php-src/ext/spl/internal cachingrecursiveiterator.inc
Modified files:
/php-src NEWS
/php-src/ext/spl php_spl.c spl.php spl_array.c spl_array.h
spl_iterators.c spl_iterators.h
/php-src/ext/spl/examples directorygraphiterator.inc
directorytreeiterator.inc
/php-src/ext/spl/tests array_009.phpt bug31926.phpt
iterator_014.phpt iterator_015.phpt
iterator_016.phpt iterator_021.phpt
iterator_022.phpt iterator_023.phpt
Log:
- Synch naming/move changes with HEAD
- Update tests/docu
# New functionality in CachingIterator/RecursiveIteratorIterator not MFHed
http://cvs.php.net/diff.php/php-src/NEWS?r1=1.2027.2.65&r2=1.2027.2.66&ty=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.65 php-src/NEWS:1.2027.2.66
--- php-src/NEWS:1.2027.2.65 Fri Sep 16 19:56:12 2005
+++ php-src/NEWS Sun Sep 18 13:15:01 2005
@@ -7,9 +7,12 @@
classes. (Dmitry, Michael Wallner)
- Added "new_link" parameter to mssql_connect(). Bug #34369. (Frank)
- Improved SPL extension. (Marcus)
- . Added RecursiveFilterIterator
+ . Moved RecursiveArrayIterator from examples into extension
+ . Moved RecursiveFilterIterator from examples into extension
. Added SplObjectStorage
. Made all SPL constants class constants
+ . Renamed CachingRecursiveIterator to RecursiveCachingIteraotr to follow
+ Recursive<*>Iterator naming scheme.
- Upgraded bundled SQLite library for PDO:SQLite to 3.2.5 (Ilia)
- Upgraded SQLite 2 library in ext/sqlite to 2.8.16 (Ilia)
- Upgraded PCRE library to version 6.2. (Andrei)
http://cvs.php.net/diff.php/php-src/ext/spl/php_spl.c?r1=1.52.2.5&r2=1.52.2.6&ty=u
Index: php-src/ext/spl/php_spl.c
diff -u php-src/ext/spl/php_spl.c:1.52.2.5 php-src/ext/spl/php_spl.c:1.52.2.6
--- php-src/ext/spl/php_spl.c:1.52.2.5 Thu Sep 15 10:08:14 2005
+++ php-src/ext/spl/php_spl.c Sun Sep 18 13:15:03 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_spl.c,v 1.52.2.5 2005/09/15 14:08:14 helly Exp $ */
+/* $Id: php_spl.c,v 1.52.2.6 2005/09/18 17:15:03 helly Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -156,7 +156,6 @@
SPL_ADD_CLASS(BadFunctionCallException, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(BadMethodCallException, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(CachingIterator, z_list, sub, allow, ce_flags); \
- SPL_ADD_CLASS(CachingRecursiveIterator, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(Countable, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(DirectoryIterator, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(DomainException, z_list, sub, allow, ce_flags); \
@@ -175,6 +174,8 @@
SPL_ADD_CLASS(OverflowException, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(ParentIterator, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(RangeException, z_list, sub, allow, ce_flags); \
+ SPL_ADD_CLASS(RecursiveArrayIterator, z_list, sub, allow, ce_flags); \
+ SPL_ADD_CLASS(RecursiveCachingIterator, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(RecursiveDirectoryIterator, z_list, sub, allow,
ce_flags); \
SPL_ADD_CLASS(RecursiveFilterIterator, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(RecursiveIterator, z_list, sub, allow, ce_flags); \
http://cvs.php.net/diff.php/php-src/ext/spl/spl.php?r1=1.49.2.3&r2=1.49.2.4&ty=u
Index: php-src/ext/spl/spl.php
diff -u php-src/ext/spl/spl.php:1.49.2.3 php-src/ext/spl/spl.php:1.49.2.4
--- php-src/ext/spl/spl.php:1.49.2.3 Thu Sep 15 10:08:14 2005
+++ php-src/ext/spl/spl.php Sun Sep 18 13:15:03 2005
@@ -40,7 +40,7 @@
* - interface SeekableIterator implements Iterator
* - class LimitIterator implements OuterIterator
* - class CachingIterator implements OuterIterator
- * - class CachingRecursiveIterator extends CachingIterator implements
RecursiveIterator
+ * - class RecursiveCachingIterator extends CachingIterator implements
RecursiveIterator
* - class IteratorIterator implements OuterIterator
* - class NoRewindIterator implements OuterIterator
* - class EmptyIterator implements Iterator
http://cvs.php.net/diff.php/php-src/ext/spl/spl_array.c?r1=1.71.2.1&r2=1.71.2.2&ty=u
Index: php-src/ext/spl/spl_array.c
diff -u php-src/ext/spl/spl_array.c:1.71.2.1
php-src/ext/spl/spl_array.c:1.71.2.2
--- php-src/ext/spl/spl_array.c:1.71.2.1 Wed Sep 14 23:33:04 2005
+++ php-src/ext/spl/spl_array.c Sun Sep 18 13:15:03 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_array.c,v 1.71.2.1 2005/09/15 03:33:04 helly Exp $ */
+/* $Id: spl_array.c,v 1.71.2.2 2005/09/18 17:15:03 helly Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -35,119 +35,22 @@
#include "spl_array.h"
#include "spl_exceptions.h"
-SPL_METHOD(Array, __construct);
-SPL_METHOD(Array, getIterator);
-SPL_METHOD(Array, rewind);
-SPL_METHOD(Array, current);
-SPL_METHOD(Array, key);
-SPL_METHOD(Array, next);
-SPL_METHOD(Array, valid);
-SPL_METHOD(Array, offsetExists);
-SPL_METHOD(Array, offsetGet);
-SPL_METHOD(Array, offsetSet);
-SPL_METHOD(Array, offsetUnset);
-SPL_METHOD(Array, append);
-SPL_METHOD(Array, getArrayCopy);
-SPL_METHOD(Array, exchangeArray);
-SPL_METHOD(Array, seek);
-SPL_METHOD(Array, count);
-SPL_METHOD(Array, getFlags);
-SPL_METHOD(Array, setFlags);
-
-static
-ZEND_BEGIN_ARG_INFO(arginfo_array___construct, 0)
- ZEND_ARG_INFO(0, array)
-ZEND_END_ARG_INFO();
-
-static
-ZEND_BEGIN_ARG_INFO_EX(arginfo_array_offsetGet, 0, 0, 1)
- ZEND_ARG_INFO(0, index)
-ZEND_END_ARG_INFO();
-
-static
-ZEND_BEGIN_ARG_INFO_EX(arginfo_array_offsetSet, 0, 0, 2)
- ZEND_ARG_INFO(0, index)
- ZEND_ARG_INFO(0, newval)
-ZEND_END_ARG_INFO();
-
-static
-ZEND_BEGIN_ARG_INFO(arginfo_array_append, 0)
- ZEND_ARG_INFO(0, value)
-ZEND_END_ARG_INFO();
-
-static
-ZEND_BEGIN_ARG_INFO(arginfo_array_seek, 0)
- ZEND_ARG_INFO(0, position)
-ZEND_END_ARG_INFO();
-
-static
-ZEND_BEGIN_ARG_INFO(arginfo_array_exchangeArray, 0)
- ZEND_ARG_INFO(0, array)
-ZEND_END_ARG_INFO();
-
-static
-ZEND_BEGIN_ARG_INFO(arginfo_array_setFlags, 0)
- ZEND_ARG_INFO(0, flags)
-ZEND_END_ARG_INFO();
-
-static zend_function_entry spl_funcs_ArrayObject[] = {
- SPL_ME(Array, __construct, arginfo_array___construct, ZEND_ACC_PUBLIC)
- SPL_ME(Array, offsetExists, arginfo_array_offsetGet, ZEND_ACC_PUBLIC)
- SPL_ME(Array, offsetGet, arginfo_array_offsetGet, ZEND_ACC_PUBLIC)
- SPL_ME(Array, offsetSet, arginfo_array_offsetSet, ZEND_ACC_PUBLIC)
- SPL_ME(Array, offsetUnset, arginfo_array_offsetGet, ZEND_ACC_PUBLIC)
- SPL_ME(Array, append, arginfo_array_append, ZEND_ACC_PUBLIC)
- SPL_ME(Array, getArrayCopy, NULL, ZEND_ACC_PUBLIC)
- SPL_ME(Array, count, NULL, ZEND_ACC_PUBLIC)
- SPL_ME(Array, getFlags, NULL, ZEND_ACC_PUBLIC)
- SPL_ME(Array, setFlags, arginfo_array_setFlags, ZEND_ACC_PUBLIC)
- /* ArrayObject specific */
- SPL_ME(Array, getIterator, NULL, ZEND_ACC_PUBLIC)
- SPL_ME(Array, exchangeArray, arginfo_array_exchangeArray,
ZEND_ACC_PUBLIC)
- {NULL, NULL, NULL}
-};
-
-static zend_function_entry spl_funcs_ArrayIterator[] = {
- SPL_ME(Array, __construct, arginfo_array___construct, ZEND_ACC_PUBLIC)
- SPL_ME(Array, offsetExists, arginfo_array_offsetGet, ZEND_ACC_PUBLIC)
- SPL_ME(Array, offsetGet, arginfo_array_offsetGet, ZEND_ACC_PUBLIC)
- SPL_ME(Array, offsetSet, arginfo_array_offsetSet, ZEND_ACC_PUBLIC)
- SPL_ME(Array, offsetUnset, arginfo_array_offsetGet, ZEND_ACC_PUBLIC)
- SPL_ME(Array, append, arginfo_array_append, ZEND_ACC_PUBLIC)
- SPL_ME(Array, getArrayCopy, NULL, ZEND_ACC_PUBLIC)
- SPL_ME(Array, count, NULL, ZEND_ACC_PUBLIC)
- SPL_ME(Array, getFlags, NULL, ZEND_ACC_PUBLIC)
- SPL_ME(Array, setFlags, arginfo_array_setFlags, ZEND_ACC_PUBLIC)
- /* ArrayIterator specific */
- SPL_ME(Array, rewind, NULL, ZEND_ACC_PUBLIC)
- SPL_ME(Array, current, NULL, ZEND_ACC_PUBLIC)
- SPL_ME(Array, key, NULL, ZEND_ACC_PUBLIC)
- SPL_ME(Array, next, NULL, ZEND_ACC_PUBLIC)
- SPL_ME(Array, valid, NULL, ZEND_ACC_PUBLIC)
- SPL_ME(Array, seek, arginfo_array_seek, ZEND_ACC_PUBLIC)
- {NULL, NULL, NULL}
-};
-
-static zend_function_entry spl_funcs_Countable[] = {
- SPL_ABSTRACT_ME(Countable, count, NULL)
- {NULL, NULL, NULL}
-};
-
zend_object_handlers spl_handler_ArrayObject;
PHPAPI zend_class_entry *spl_ce_ArrayObject;
zend_object_handlers spl_handler_ArrayIterator;
PHPAPI zend_class_entry *spl_ce_ArrayIterator;
+PHPAPI zend_class_entry *spl_ce_RecursiveArrayIterator;
PHPAPI zend_class_entry *spl_ce_Countable;
-#define SPL_ARRAY_STD_PROP_LIST 0x00000001
-#define SPL_ARRAY_ARRAY_AS_PROPS 0x00000002
-#define SPL_ARRAY_IS_REF 0x01000000
-#define SPL_ARRAY_IS_SELF 0x02000000
-#define SPL_ARRAY_USE_OTHER 0x04000000
-#define SPL_ARRAY_INT_MASK 0xFF000000
-#define SPL_ARRAY_CLONE_MASK 0x03000003
+#define SPL_ARRAY_STD_PROP_LIST 0x00000001
+#define SPL_ARRAY_ARRAY_AS_PROPS 0x00000002
+#define SPL_ARRAY_IS_REF 0x01000000
+#define SPL_ARRAY_IS_SELF 0x02000000
+#define SPL_ARRAY_USE_OTHER 0x04000000
+#define SPL_ARRAY_INT_MASK 0xFF000000
+#define SPL_ARRAY_CLONE_MASK 0x03000007
typedef struct _spl_array_object {
zend_object std;
@@ -160,6 +63,7 @@
zend_function * fptr_offset_set;
zend_function * fptr_offset_has;
zend_function * fptr_offset_del;
+ zend_class_entry* ce_get_iterator;
} spl_array_object;
static inline HashTable *spl_array_get_hash_table(spl_array_object* intern,
int check_std_props TSRMLS_DC) {
@@ -275,6 +179,7 @@
intern->fptr_offset_del = NULL;
}
}
+ intern->ce_get_iterator = spl_ce_ArrayIterator;
zend_hash_internal_pointer_reset_ex(spl_array_get_hash_table(intern, 0
TSRMLS_CC), &intern->pos);
return retval;
}
@@ -543,7 +448,7 @@
Sets the value at the specified $index to $newval. */
SPL_METHOD(Array, offsetSet)
{
- zval *index, *value = NULL;
+ zval *index, *value;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &index,
&value) == FAILURE) {
return;
}
@@ -855,7 +760,7 @@
}
/* }}} */
-/* {{{ proto void ArrayObject::__construct(array|object ar = array())
+/* {{{ proto void ArrayObject::__construct(array|object ar = array() [, int
flags = 0 [, string iterator_class = "ArrayIterator"]])
proto void ArrayIterator::__construct(array|object ar = array() [, int
flags = 0])
Cronstructs a new array iterator from a path. */
SPL_METHOD(Array, __construct)
@@ -864,6 +769,9 @@
spl_array_object *intern;
zval *array;
long ar_flags = 0;
+ char *class_name;
+ int class_name_len;
+ zend_class_entry ** pce_get_iterator;
if (ZEND_NUM_ARGS() == 0) {
return; /* nothing to do */
@@ -872,11 +780,20 @@
intern = (spl_array_object*)zend_object_store_get_object(object
TSRMLS_CC);
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &array,
&ar_flags) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|ls", &array,
&ar_flags, &class_name, &class_name_len) == FAILURE) {
php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
return;
}
+ if (ZEND_NUM_ARGS() > 2) {
+ if (zend_lookup_class(class_name, class_name_len,
&pce_get_iterator TSRMLS_CC) == FAILURE) {
+ zend_throw_exception(spl_ce_InvalidArgumentException,
"A class that implements Iterator must be specified", 0 TSRMLS_CC);
+ php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
+ return;
+ }
+ intern->ce_get_iterator = *pce_get_iterator;
+ }
+
ar_flags &= ~SPL_ARRAY_INT_MASK;
if (Z_TYPE_P(array) == IS_OBJECT && (Z_OBJ_HT_P(array) ==
&spl_handler_ArrayObject || Z_OBJ_HT_P(array) == &spl_handler_ArrayIterator)) {
@@ -911,6 +828,41 @@
}
/* }}} */
+/* {{{ proto void ArrayObject::setIteratorClass(string iterator_class)
+ Set the class used in getIterator. */
+SPL_METHOD(Array, setIteratorClass)
+{
+ zval *object = getThis();
+ spl_array_object *intern =
(spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
+ char *class_name;
+ int class_name_len;
+ zend_class_entry ** pce_get_iterator;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &class_name,
&class_name_len) == FAILURE) {
+ php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
+ return;
+ }
+
+ if (zend_lookup_class(class_name, class_name_len, &pce_get_iterator
TSRMLS_CC) == FAILURE) {
+ zend_throw_exception(spl_ce_InvalidArgumentException, "A class
that implements Iterator must be specified", 0 TSRMLS_CC);
+ php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
+ return;
+ }
+ intern->ce_get_iterator = *pce_get_iterator;
+}
+/* }}} */
+
+/* {{{ proto string ArrayObject::getIteratorClass()
+ Get the class used in getIterator. */
+SPL_METHOD(Array, getIteratorClass)
+{
+ zval *object = getThis();
+ spl_array_object *intern =
(spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
+
+ RETURN_STRING(intern->ce_get_iterator->name, 1);
+}
+/* }}} */
+
/* {{{ proto int ArrayObject::getFlags()
Get flags */
SPL_METHOD(Array, getFlags)
@@ -994,7 +946,7 @@
}
return_value->type = IS_OBJECT;
- return_value->value.obj = spl_array_object_new_ex(spl_ce_ArrayIterator,
&iterator, object TSRMLS_CC);
+ return_value->value.obj =
spl_array_object_new_ex(intern->ce_get_iterator, &iterator, object TSRMLS_CC);
return_value->refcount = 1;
return_value->is_ref = 1;
}
@@ -1187,6 +1139,150 @@
}
/* }}} */
+/* {{{ proto bool RecursiveArrayIterator::hasChildren()
+ Check whether current element has children (e.g. is an array) */
+SPL_METHOD(Array, hasChildren)
+{
+ zval *object = getThis(), **entry;
+ spl_array_object *intern =
(spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
+ HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
+
+ if (!aht) {
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified
outside object and is no longer an array");
+ RETURN_FALSE;
+ }
+
+ if ((intern->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos(intern
TSRMLS_CC) == FAILURE) {
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified
outside object and internal position is no longer valid");
+ RETURN_FALSE;
+ }
+
+ if (zend_hash_get_current_data_ex(aht, (void **) &entry, &intern->pos)
== FAILURE) {
+ RETURN_FALSE;
+ }
+
+ RETURN_BOOL(Z_TYPE_PP(entry) == IS_ARRAY || Z_TYPE_PP(entry) ==
IS_OBJECT);
+}
+/* }}} */
+
+/* {{{ proto object RecursiveArrayIterator::getChildren()
+ Create a sub iterator for the current element (same class as $this) */
+SPL_METHOD(Array, getChildren)
+{
+ zval *object = getThis(), **entry;
+ spl_array_object *intern =
(spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
+ HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
+
+ if (!aht) {
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified
outside object and is no longer an array");
+ return;
+ }
+
+ if ((intern->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos(intern
TSRMLS_CC) == FAILURE) {
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified
outside object and internal position is no longer valid");
+ return;
+ }
+
+ if (zend_hash_get_current_data_ex(aht, (void **) &entry, &intern->pos)
== FAILURE) {
+ return;
+ }
+
+ spl_instantiate_arg_ex1(Z_OBJCE_P(getThis()), &return_value, 0, *entry
TSRMLS_CC);
+}
+/* }}} */
+
+static
+ZEND_BEGIN_ARG_INFO(arginfo_array___construct, 0)
+ ZEND_ARG_INFO(0, array)
+ZEND_END_ARG_INFO();
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_array_offsetGet, 0, 0, 1)
+ ZEND_ARG_INFO(0, index)
+ZEND_END_ARG_INFO();
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_array_offsetSet, 0, 0, 2)
+ ZEND_ARG_INFO(0, index)
+ ZEND_ARG_INFO(0, newval)
+ZEND_END_ARG_INFO();
+
+static
+ZEND_BEGIN_ARG_INFO(arginfo_array_append, 0)
+ ZEND_ARG_INFO(0, value)
+ZEND_END_ARG_INFO();
+
+static
+ZEND_BEGIN_ARG_INFO(arginfo_array_seek, 0)
+ ZEND_ARG_INFO(0, position)
+ZEND_END_ARG_INFO();
+
+static
+ZEND_BEGIN_ARG_INFO(arginfo_array_exchangeArray, 0)
+ ZEND_ARG_INFO(0, array)
+ZEND_END_ARG_INFO();
+
+static
+ZEND_BEGIN_ARG_INFO(arginfo_array_setFlags, 0)
+ ZEND_ARG_INFO(0, flags)
+ZEND_END_ARG_INFO();
+
+static
+ZEND_BEGIN_ARG_INFO(arginfo_array_setIteratorClass, 0)
+ ZEND_ARG_INFO(0, iteratorClass)
+ZEND_END_ARG_INFO();
+
+static zend_function_entry spl_funcs_ArrayObject[] = {
+ SPL_ME(Array, __construct, arginfo_array___construct, ZEND_ACC_PUBLIC)
+ SPL_ME(Array, offsetExists, arginfo_array_offsetGet, ZEND_ACC_PUBLIC)
+ SPL_ME(Array, offsetGet, arginfo_array_offsetGet, ZEND_ACC_PUBLIC)
+ SPL_ME(Array, offsetSet, arginfo_array_offsetSet, ZEND_ACC_PUBLIC)
+ SPL_ME(Array, offsetUnset, arginfo_array_offsetGet, ZEND_ACC_PUBLIC)
+ SPL_ME(Array, append, arginfo_array_append, ZEND_ACC_PUBLIC)
+ SPL_ME(Array, getArrayCopy, NULL, ZEND_ACC_PUBLIC)
+ SPL_ME(Array, count, NULL, ZEND_ACC_PUBLIC)
+ SPL_ME(Array, getFlags, NULL, ZEND_ACC_PUBLIC)
+ SPL_ME(Array, setFlags, arginfo_array_setFlags, ZEND_ACC_PUBLIC)
+ /* ArrayObject specific */
+ SPL_ME(Array, getIterator, NULL,
ZEND_ACC_PUBLIC)
+ SPL_ME(Array, exchangeArray, arginfo_array_exchangeArray,
ZEND_ACC_PUBLIC)
+ SPL_ME(Array, setIteratorClass, arginfo_array_setIteratorClass,
ZEND_ACC_PUBLIC)
+ SPL_ME(Array, getIteratorClass, NULL,
ZEND_ACC_PUBLIC)
+ {NULL, NULL, NULL}
+};
+
+static zend_function_entry spl_funcs_ArrayIterator[] = {
+ SPL_ME(Array, __construct, arginfo_array___construct, ZEND_ACC_PUBLIC)
+ SPL_ME(Array, offsetExists, arginfo_array_offsetGet, ZEND_ACC_PUBLIC)
+ SPL_ME(Array, offsetGet, arginfo_array_offsetGet, ZEND_ACC_PUBLIC)
+ SPL_ME(Array, offsetSet, arginfo_array_offsetSet, ZEND_ACC_PUBLIC)
+ SPL_ME(Array, offsetUnset, arginfo_array_offsetGet, ZEND_ACC_PUBLIC)
+ SPL_ME(Array, append, arginfo_array_append, ZEND_ACC_PUBLIC)
+ SPL_ME(Array, getArrayCopy, NULL, ZEND_ACC_PUBLIC)
+ SPL_ME(Array, count, NULL, ZEND_ACC_PUBLIC)
+ SPL_ME(Array, getFlags, NULL, ZEND_ACC_PUBLIC)
+ SPL_ME(Array, setFlags, arginfo_array_setFlags, ZEND_ACC_PUBLIC)
+ /* ArrayIterator specific */
+ SPL_ME(Array, rewind, NULL, ZEND_ACC_PUBLIC)
+ SPL_ME(Array, current, NULL, ZEND_ACC_PUBLIC)
+ SPL_ME(Array, key, NULL, ZEND_ACC_PUBLIC)
+ SPL_ME(Array, next, NULL, ZEND_ACC_PUBLIC)
+ SPL_ME(Array, valid, NULL, ZEND_ACC_PUBLIC)
+ SPL_ME(Array, seek, arginfo_array_seek, ZEND_ACC_PUBLIC)
+ {NULL, NULL, NULL}
+};
+
+static zend_function_entry spl_funcs_RecursiveArrayIterator[] = {
+ SPL_ME(Array, hasChildren, NULL, ZEND_ACC_PUBLIC)
+ SPL_ME(Array, getChildren, NULL, ZEND_ACC_PUBLIC)
+ {NULL, NULL, NULL}
+};
+
+static zend_function_entry spl_funcs_Countable[] = {
+ SPL_ABSTRACT_ME(Countable, count, NULL)
+ {NULL, NULL, NULL}
+};
+
/* {{{ PHP_MINIT_FUNCTION(spl_array) */
PHP_MINIT_FUNCTION(spl_array)
{
@@ -1214,6 +1310,9 @@
REGISTER_SPL_IMPLEMENTS(ArrayIterator, SeekableIterator);
memcpy(&spl_handler_ArrayIterator, &spl_handler_ArrayObject,
sizeof(zend_object_handlers));
spl_ce_ArrayIterator->get_iterator = spl_array_get_iterator;
+
+ REGISTER_SPL_SUB_CLASS_EX(RecursiveArrayIterator, ArrayIterator,
spl_array_object_new, spl_funcs_RecursiveArrayIterator);
+ REGISTER_SPL_IMPLEMENTS(RecursiveArrayIterator, RecursiveIterator);
REGISTER_SPL_INTERFACE(Countable);
http://cvs.php.net/diff.php/php-src/ext/spl/spl_array.h?r1=1.13&r2=1.13.2.1&ty=u
Index: php-src/ext/spl/spl_array.h
diff -u php-src/ext/spl/spl_array.h:1.13 php-src/ext/spl/spl_array.h:1.13.2.1
--- php-src/ext/spl/spl_array.h:1.13 Wed Aug 3 10:07:53 2005
+++ php-src/ext/spl/spl_array.h Sun Sep 18 13:15:04 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_array.h,v 1.13 2005/08/03 14:07:53 sniper Exp $ */
+/* $Id: spl_array.h,v 1.13.2.1 2005/09/18 17:15:04 helly Exp $ */
#ifndef SPL_ARRAY_H
#define SPL_ARRAY_H
@@ -26,6 +26,7 @@
extern PHPAPI zend_class_entry *spl_ce_ArrayObject;
extern PHPAPI zend_class_entry *spl_ce_ArrayIterator;
+extern PHPAPI zend_class_entry *spl_ce_RecursiveArrayIterator;
extern PHPAPI zend_class_entry *spl_ce_Countable;
PHP_MINIT_FUNCTION(spl_array);
http://cvs.php.net/diff.php/php-src/ext/spl/spl_iterators.c?r1=1.73.2.1&r2=1.73.2.2&ty=u
Index: php-src/ext/spl/spl_iterators.c
diff -u php-src/ext/spl/spl_iterators.c:1.73.2.1
php-src/ext/spl/spl_iterators.c:1.73.2.2
--- php-src/ext/spl/spl_iterators.c:1.73.2.1 Wed Sep 14 23:33:04 2005
+++ php-src/ext/spl/spl_iterators.c Sun Sep 18 13:15:04 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_iterators.c,v 1.73.2.1 2005/09/15 03:33:04 helly Exp $ */
+/* $Id: spl_iterators.c,v 1.73.2.2 2005/09/18 17:15:04 helly Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -46,7 +46,7 @@
PHPAPI zend_class_entry *spl_ce_SeekableIterator;
PHPAPI zend_class_entry *spl_ce_LimitIterator;
PHPAPI zend_class_entry *spl_ce_CachingIterator;
-PHPAPI zend_class_entry *spl_ce_CachingRecursiveIterator;
+PHPAPI zend_class_entry *spl_ce_RecursiveCachingIterator;
PHPAPI zend_class_entry *spl_ce_OuterIterator;
PHPAPI zend_class_entry *spl_ce_IteratorIterator;
PHPAPI zend_class_entry *spl_ce_NoRewindIterator;
@@ -758,7 +758,7 @@
break;
}
case DIT_CachingIterator:
- case DIT_CachingRecursiveIterator: {
+ case DIT_RecursiveCachingIterator: {
long flags = CIT_CALL_TOSTRING;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"O|l", &zobject, ce_inner, &flags) == FAILURE) {
php_set_error_handling(EH_NORMAL, NULL
TSRMLS_CC);
@@ -868,7 +868,7 @@
efree(intern->current.str_key);
intern->current.str_key = NULL;
}
- if (intern->dit_type == DIT_CachingIterator || intern->dit_type ==
DIT_CachingRecursiveIterator) {
+ if (intern->dit_type == DIT_CachingIterator || intern->dit_type ==
DIT_RecursiveCachingIterator) {
if (intern->u.caching.zstr) {
zval_ptr_dtor(&intern->u.caching.zstr);
intern->u.caching.zstr = NULL;
@@ -1384,7 +1384,7 @@
{
if (spl_dual_it_fetch(intern, 1 TSRMLS_CC) == SUCCESS) {
intern->u.caching.flags |= CIT_VALID;
- if (intern->dit_type == DIT_CachingRecursiveIterator) {
+ if (intern->dit_type == DIT_RecursiveCachingIterator) {
zval *retval, *zchildren, zflags;
zend_call_method_with_0_params(&intern->inner.zobject,
intern->inner.ce, NULL, "haschildren", &retval);
if (zend_is_true(retval)) {
@@ -1397,7 +1397,7 @@
} else {
INIT_PZVAL(&zflags);
ZVAL_LONG(&zflags,
intern->u.caching.flags & CIT_PUBLIC);
-
spl_instantiate_arg_ex2(spl_ce_CachingRecursiveIterator,
&intern->u.caching.zchildren, 1, zchildren, &zflags TSRMLS_CC);
+
spl_instantiate_arg_ex2(spl_ce_RecursiveCachingIterator,
&intern->u.caching.zchildren, 1, zchildren, &zflags TSRMLS_CC);
zval_ptr_dtor(&zchildren);
}
}
@@ -1546,16 +1546,16 @@
{NULL, NULL, NULL}
};
-/* {{{ proto CachingRecursiveIterator::__construct(RecursiveIterator it [,
flags = CIT_CALL_TOSTRING])
+/* {{{ proto RecursiveCachingIterator::__construct(RecursiveIterator it [,
flags = CIT_CALL_TOSTRING])
Create an iterator from a RecursiveIterator */
-SPL_METHOD(CachingRecursiveIterator, __construct)
+SPL_METHOD(RecursiveCachingIterator, __construct)
{
- spl_dual_it_construct(INTERNAL_FUNCTION_PARAM_PASSTHRU,
spl_ce_RecursiveIterator, DIT_CachingRecursiveIterator);
+ spl_dual_it_construct(INTERNAL_FUNCTION_PARAM_PASSTHRU,
spl_ce_RecursiveIterator, DIT_RecursiveCachingIterator);
} /* }}} */
-/* {{{ proto bolean CachingRecursiveIterator::hasChildren()
+/* {{{ proto bolean RecursiveCachingIterator::hasChildren()
Check whether the current element of the inner iterator has children */
-SPL_METHOD(CachingRecursiveIterator, hasChildren)
+SPL_METHOD(RecursiveCachingIterator, hasChildren)
{
spl_dual_it_object *intern;
@@ -1564,9 +1564,9 @@
RETURN_BOOL(intern->u.caching.zchildren);
} /* }}} */
-/* {{{ proto CachingRecursiveIterator CachingRecursiveIterator::getChildren()
- Return the inner iterator's children as a CachingRecursiveIterator */
-SPL_METHOD(CachingRecursiveIterator, getChildren)
+/* {{{ proto RecursiveCachingIterator RecursiveCachingIterator::getChildren()
+ Return the inner iterator's children as a RecursiveCachingIterator */
+SPL_METHOD(RecursiveCachingIterator, getChildren)
{
spl_dual_it_object *intern;
@@ -1585,10 +1585,10 @@
ZEND_ARG_INFO(0, flags)
ZEND_END_ARG_INFO();
-static zend_function_entry spl_funcs_CachingRecursiveIterator[] = {
- SPL_ME(CachingRecursiveIterator, __construct,
arginfo_caching_rec_it___construct, ZEND_ACC_PUBLIC)
- SPL_ME(CachingRecursiveIterator, hasChildren, NULL, ZEND_ACC_PUBLIC)
- SPL_ME(CachingRecursiveIterator, getChildren, NULL, ZEND_ACC_PUBLIC)
+static zend_function_entry spl_funcs_RecursiveCachingIterator[] = {
+ SPL_ME(RecursiveCachingIterator, __construct,
arginfo_caching_rec_it___construct, ZEND_ACC_PUBLIC)
+ SPL_ME(RecursiveCachingIterator, hasChildren, NULL, ZEND_ACC_PUBLIC)
+ SPL_ME(RecursiveCachingIterator, getChildren, NULL, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
};
@@ -2021,8 +2021,8 @@
REGISTER_SPL_CLASS_CONST_LONG(CachingIterator, "CALL_TOSTRING",
CIT_CALL_TOSTRING);
REGISTER_SPL_CLASS_CONST_LONG(CachingIterator, "CATCH_GET_CHILD",
CIT_CATCH_GET_CHILD);
- REGISTER_SPL_SUB_CLASS_EX(CachingRecursiveIterator, CachingIterator,
spl_dual_it_new, spl_funcs_CachingRecursiveIterator);
- REGISTER_SPL_IMPLEMENTS(CachingRecursiveIterator, RecursiveIterator);
+ REGISTER_SPL_SUB_CLASS_EX(RecursiveCachingIterator, CachingIterator,
spl_dual_it_new, spl_funcs_RecursiveCachingIterator);
+ REGISTER_SPL_IMPLEMENTS(RecursiveCachingIterator, RecursiveIterator);
REGISTER_SPL_STD_CLASS_EX(IteratorIterator, spl_dual_it_new,
spl_funcs_IteratorIterator);
REGISTER_SPL_ITERATOR(IteratorIterator);
http://cvs.php.net/diff.php/php-src/ext/spl/spl_iterators.h?r1=1.18.2.1&r2=1.18.2.2&ty=u
Index: php-src/ext/spl/spl_iterators.h
diff -u php-src/ext/spl/spl_iterators.h:1.18.2.1
php-src/ext/spl/spl_iterators.h:1.18.2.2
--- php-src/ext/spl/spl_iterators.h:1.18.2.1 Wed Sep 14 23:33:04 2005
+++ php-src/ext/spl/spl_iterators.h Sun Sep 18 13:15:04 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_iterators.h,v 1.18.2.1 2005/09/15 03:33:04 helly Exp $ */
+/* $Id: spl_iterators.h,v 1.18.2.2 2005/09/18 17:15:04 helly Exp $ */
#ifndef SPL_ITERATORS_H
#define SPL_ITERATORS_H
@@ -38,7 +38,7 @@
extern PHPAPI zend_class_entry *spl_ce_SeekableIterator;
extern PHPAPI zend_class_entry *spl_ce_LimitIterator;
extern PHPAPI zend_class_entry *spl_ce_CachingIterator;
-extern PHPAPI zend_class_entry *spl_ce_CachingRecursiveIterator;
+extern PHPAPI zend_class_entry *spl_ce_RecursiveCachingIterator;
extern PHPAPI zend_class_entry *spl_ce_OuterIterator;
extern PHPAPI zend_class_entry *spl_ce_IteratorIterator;
extern PHPAPI zend_class_entry *spl_ce_NoRewindIterator;
@@ -55,7 +55,7 @@
DIT_Default = 0,
DIT_LimitIterator,
DIT_CachingIterator,
- DIT_CachingRecursiveIterator,
+ DIT_RecursiveCachingIterator,
DIT_IteratorIterator,
DIT_NoRewindIterator,
DIT_InfiniteIterator,
http://cvs.php.net/diff.php/php-src/ext/spl/examples/directorygraphiterator.inc?r1=1.7.2.1&r2=1.7.2.2&ty=u
Index: php-src/ext/spl/examples/directorygraphiterator.inc
diff -u php-src/ext/spl/examples/directorygraphiterator.inc:1.7.2.1
php-src/ext/spl/examples/directorygraphiterator.inc:1.7.2.2
--- php-src/ext/spl/examples/directorygraphiterator.inc:1.7.2.1 Wed Sep 14
23:33:04 2005
+++ php-src/ext/spl/examples/directorygraphiterator.inc Sun Sep 18 13:15:04 2005
@@ -18,7 +18,7 @@
{
function __construct($path)
{
- RecursiveIteratorIterator::__construct(new
CachingRecursiveIterator(new ParentIterator(new
RecursiveDirectoryIterator($path)),
CachingIterator::CALL_TOSTRING|CachingIterator::CATCH_GET_CHILD), 1);
+ RecursiveIteratorIterator::__construct(new
RecursiveCachingIterator(new ParentIterator(new
RecursiveDirectoryIterator($path)),
CachingIterator::CALL_TOSTRING|CachingIterator::CATCH_GET_CHILD), 1);
}
}
http://cvs.php.net/diff.php/php-src/ext/spl/examples/directorytreeiterator.inc?r1=1.13.2.1&r2=1.13.2.2&ty=u
Index: php-src/ext/spl/examples/directorytreeiterator.inc
diff -u php-src/ext/spl/examples/directorytreeiterator.inc:1.13.2.1
php-src/ext/spl/examples/directorytreeiterator.inc:1.13.2.2
--- php-src/ext/spl/examples/directorytreeiterator.inc:1.13.2.1 Wed Sep 14
23:33:04 2005
+++ php-src/ext/spl/examples/directorytreeiterator.inc Sun Sep 18 13:15:04 2005
@@ -21,7 +21,7 @@
*/
function __construct($path)
{
- parent::__construct(new CachingRecursiveIterator(new
RecursiveDirectoryIterator($path),
CachingIterator::CALL_TOSTRING|CachingIterator::CATCH_GET_CHILD), 1);
+ parent::__construct(new RecursiveCachingIterator(new
RecursiveDirectoryIterator($path),
CachingIterator::CALL_TOSTRING|CachingIterator::CATCH_GET_CHILD), 1);
}
/** @return the current element prefixed with ASCII graphics
http://cvs.php.net/diff.php/php-src/ext/spl/tests/array_009.phpt?r1=1.3.2.1&r2=1.3.2.2&ty=u
Index: php-src/ext/spl/tests/array_009.phpt
diff -u php-src/ext/spl/tests/array_009.phpt:1.3.2.1
php-src/ext/spl/tests/array_009.phpt:1.3.2.2
--- php-src/ext/spl/tests/array_009.phpt:1.3.2.1 Wed Sep 14 23:33:04 2005
+++ php-src/ext/spl/tests/array_009.phpt Sun Sep 18 13:15:04 2005
@@ -5,22 +5,9 @@
--FILE--
<?php
-class RecursiceArrayIterator extends ArrayIterator implements RecursiveIterator
-{
- function hasChildren()
- {
- return is_array($this->current());
- }
-
- function getChildren()
- {
- return new RecursiceArrayIterator($this->current());
- }
-}
-
$array = array(1, 2 => array(21, 22 => array(221, 222), 23 => array(231)), 3);
-$dir = new RecursiveIteratorIterator(new RecursiceArrayIterator($array),
RecursiveIteratorIterator::LEAVES_ONLY);
+$dir = new RecursiveIteratorIterator(new RecursiveArrayIterator($array),
RecursiveIteratorIterator::LEAVES_ONLY);
foreach ($dir as $file) {
print "$file\n";
http://cvs.php.net/diff.php/php-src/ext/spl/tests/bug31926.phpt?r1=1.1&r2=1.1.4.1&ty=u
Index: php-src/ext/spl/tests/bug31926.phpt
diff -u php-src/ext/spl/tests/bug31926.phpt:1.1
php-src/ext/spl/tests/bug31926.phpt:1.1.4.1
--- php-src/ext/spl/tests/bug31926.phpt:1.1 Sat Feb 12 13:40:19 2005
+++ php-src/ext/spl/tests/bug31926.phpt Sun Sep 18 13:15:04 2005
@@ -5,17 +5,6 @@
$array = array(0 => array('world'));
-class RecursiveArrayIterator extends ArrayIterator implements
-RecursiveIterator {
- function hasChildren() {
- return (is_array($this->current()));
- }
-
- function getChildren() {
- return new self($this->current());
- }
-}
-
$it = new RecursiveIteratorIterator(new RecursiveArrayIterator($array));
foreach($it as $key => $val) {
var_dump($key, $val);
http://cvs.php.net/diff.php/php-src/ext/spl/tests/iterator_014.phpt?r1=1.2&r2=1.2.2.1&ty=u
Index: php-src/ext/spl/tests/iterator_014.phpt
diff -u php-src/ext/spl/tests/iterator_014.phpt:1.2
php-src/ext/spl/tests/iterator_014.phpt:1.2.2.1
--- php-src/ext/spl/tests/iterator_014.phpt:1.2 Thu May 19 11:49:44 2005
+++ php-src/ext/spl/tests/iterator_014.phpt Sun Sep 18 13:15:04 2005
@@ -3,19 +3,8 @@
--FILE--
<?php
-class RecursiveArrayIterator extends ArrayIterator implements RecursiveIterator
+class MyRecursiveArrayIterator extends RecursiveArrayIterator
{
- function hasChildren()
- {
- return is_array($this->current());
- }
-
- function getChildren()
- {
- echo __METHOD__ . "\n";
- return new RecursiveArrayIterator($this->current());
- }
-
function valid()
{
if (!parent::valid())
@@ -28,6 +17,12 @@
return true;
}
}
+
+ function getChildren()
+ {
+ echo __METHOD__ . "\n";
+ return parent::getChildren();
+ }
}
class RecursiveArrayIteratorIterator extends RecursiveIteratorIterator
@@ -73,7 +68,7 @@
}
}
-foreach(new RecursiveArrayIteratorIterator(new
RecursiveArrayIterator(array("a", array("ba", array("bba", "bbb"),
array(array("bcaa"))), array("ca"), "d"))) as $k=>$v)
+foreach(new RecursiveArrayIteratorIterator(new
MyRecursiveArrayIterator(array("a", array("ba", array("bba", "bbb"),
array(array("bcaa"))), array("ca"), "d"))) as $k=>$v)
{
echo "$k=>$v\n";
}
@@ -87,14 +82,14 @@
RecursiveArrayIteratorIterator::key
0=>a
RecursiveArrayIteratorIterator::next
-RecursiveArrayIterator::getChildren
+MyRecursiveArrayIterator::getChildren
RecursiveArrayIteratorIterator::beginChildren(1)
RecursiveArrayIteratorIterator::valid
RecursiveArrayIteratorIterator::current
RecursiveArrayIteratorIterator::key
0=>ba
RecursiveArrayIteratorIterator::next
-RecursiveArrayIterator::getChildren
+MyRecursiveArrayIterator::getChildren
RecursiveArrayIteratorIterator::beginChildren(2)
RecursiveArrayIteratorIterator::valid
RecursiveArrayIteratorIterator::current
@@ -106,38 +101,38 @@
RecursiveArrayIteratorIterator::key
1=>bbb
RecursiveArrayIteratorIterator::next
-RecursiveArrayIterator::valid = false
+MyRecursiveArrayIterator::valid = false
RecursiveArrayIteratorIterator::endChildren(2)
-RecursiveArrayIterator::getChildren
+MyRecursiveArrayIterator::getChildren
RecursiveArrayIteratorIterator::beginChildren(2)
-RecursiveArrayIterator::getChildren
+MyRecursiveArrayIterator::getChildren
RecursiveArrayIteratorIterator::beginChildren(3)
RecursiveArrayIteratorIterator::valid
RecursiveArrayIteratorIterator::current
RecursiveArrayIteratorIterator::key
0=>bcaa
RecursiveArrayIteratorIterator::next
-RecursiveArrayIterator::valid = false
+MyRecursiveArrayIterator::valid = false
RecursiveArrayIteratorIterator::endChildren(3)
-RecursiveArrayIterator::valid = false
+MyRecursiveArrayIterator::valid = false
RecursiveArrayIteratorIterator::endChildren(2)
-RecursiveArrayIterator::valid = false
+MyRecursiveArrayIterator::valid = false
RecursiveArrayIteratorIterator::endChildren(1)
-RecursiveArrayIterator::getChildren
+MyRecursiveArrayIterator::getChildren
RecursiveArrayIteratorIterator::beginChildren(1)
RecursiveArrayIteratorIterator::valid
RecursiveArrayIteratorIterator::current
RecursiveArrayIteratorIterator::key
0=>ca
RecursiveArrayIteratorIterator::next
-RecursiveArrayIterator::valid = false
+MyRecursiveArrayIterator::valid = false
RecursiveArrayIteratorIterator::endChildren(1)
RecursiveArrayIteratorIterator::valid
RecursiveArrayIteratorIterator::current
RecursiveArrayIteratorIterator::key
3=>d
RecursiveArrayIteratorIterator::next
-RecursiveArrayIterator::valid = false
+MyRecursiveArrayIterator::valid = false
RecursiveArrayIteratorIterator::valid
-RecursiveArrayIterator::valid = false
+MyRecursiveArrayIterator::valid = false
===DONE===
http://cvs.php.net/diff.php/php-src/ext/spl/tests/iterator_015.phpt?r1=1.2&r2=1.2.2.1&ty=u
Index: php-src/ext/spl/tests/iterator_015.phpt
diff -u php-src/ext/spl/tests/iterator_015.phpt:1.2
php-src/ext/spl/tests/iterator_015.phpt:1.2.2.1
--- php-src/ext/spl/tests/iterator_015.phpt:1.2 Thu May 19 11:49:44 2005
+++ php-src/ext/spl/tests/iterator_015.phpt Sun Sep 18 13:15:04 2005
@@ -3,19 +3,6 @@
--FILE--
<?php
-class RecursiveArrayIterator extends ArrayIterator implements RecursiveIterator
-{
- function hasChildren()
- {
- return is_array($this->current());
- }
-
- function getChildren()
- {
- return new RecursiveArrayIterator($this->current());
- }
-}
-
class RecursiveArrayIteratorIterator extends RecursiveIteratorIterator
{
function rewind()
http://cvs.php.net/diff.php/php-src/ext/spl/tests/iterator_016.phpt?r1=1.2&r2=1.2.2.1&ty=u
Index: php-src/ext/spl/tests/iterator_016.phpt
diff -u php-src/ext/spl/tests/iterator_016.phpt:1.2
php-src/ext/spl/tests/iterator_016.phpt:1.2.2.1
--- php-src/ext/spl/tests/iterator_016.phpt:1.2 Thu May 19 11:49:44 2005
+++ php-src/ext/spl/tests/iterator_016.phpt Sun Sep 18 13:15:04 2005
@@ -3,19 +3,6 @@
--FILE--
<?php
-class RecursiveArrayIterator extends ArrayIterator implements RecursiveIterator
-{
- function hasChildren()
- {
- return is_array($this->current());
- }
-
- function getChildren()
- {
- return new RecursiveArrayIterator($this->current());
- }
-}
-
class Menu extends ArrayObject
{
function getIterator()
http://cvs.php.net/diff.php/php-src/ext/spl/tests/iterator_021.phpt?r1=1.2&r2=1.2.2.1&ty=u
Index: php-src/ext/spl/tests/iterator_021.phpt
diff -u php-src/ext/spl/tests/iterator_021.phpt:1.2
php-src/ext/spl/tests/iterator_021.phpt:1.2.2.1
--- php-src/ext/spl/tests/iterator_021.phpt:1.2 Thu May 19 11:49:44 2005
+++ php-src/ext/spl/tests/iterator_021.phpt Sun Sep 18 13:15:04 2005
@@ -3,19 +3,8 @@
--FILE--
<?php
-class RecursiveArrayIterator extends ArrayIterator implements RecursiveIterator
+class MyRecursiveArrayIterator extends RecursiveArrayIterator
{
- function hasChildren()
- {
- return is_array($this->current());
- }
-
- function getChildren()
- {
- echo __METHOD__ . "\n";
- return new RecursiveArrayIterator($this->current());
- }
-
function valid()
{
if (!parent::valid())
@@ -28,6 +17,12 @@
return true;
}
}
+
+ function getChildren()
+ {
+ echo __METHOD__ . "\n";
+ return parent::getChildren();
+ }
}
class RecursiveArrayIteratorIterator extends RecursiveIteratorIterator
@@ -105,7 +100,7 @@
}
}
-foreach(new RecursiveArrayIteratorIterator(new
RecursiveArrayIterator(array("a", array("ba", array("bba", "bbb"),
array(array("bcaa"), array("bcba"))), array("ca"), "d")), 2) as $k=>$v)
+foreach(new RecursiveArrayIteratorIterator(new
MyRecursiveArrayIterator(array("a", array("ba", array("bba", "bbb"),
array(array("bcaa"), array("bcba"))), array("ca"), "d")), 2) as $k=>$v)
{
if (is_array($v)) $v = join('',$v);
echo "$k=>$v\n";
@@ -122,7 +117,7 @@
0=>a
RecursiveArrayIteratorIterator::next
RecursiveArrayIteratorIterator::callHasChildren(0) = yes/yes
-RecursiveArrayIterator::getChildren
+MyRecursiveArrayIterator::getChildren
RecursiveArrayIteratorIterator::beginChildren(1)
RecursiveArrayIteratorIterator::callHasChildren(1) = no/no
RecursiveArrayIteratorIterator::valid
@@ -131,7 +126,7 @@
0=>ba
RecursiveArrayIteratorIterator::next
RecursiveArrayIteratorIterator::callHasChildren(1) = yes/yes
-RecursiveArrayIterator::getChildren
+MyRecursiveArrayIterator::getChildren
RecursiveArrayIteratorIterator::beginChildren(2)
RecursiveArrayIteratorIterator::callHasChildren(2) = no/no
RecursiveArrayIteratorIterator::valid
@@ -145,10 +140,10 @@
RecursiveArrayIteratorIterator::key
1=>bbb
RecursiveArrayIteratorIterator::next
-RecursiveArrayIterator::valid = false
+MyRecursiveArrayIterator::valid = false
RecursiveArrayIteratorIterator::endChildren(2)
RecursiveArrayIteratorIterator::callHasChildren(1) = yes/yes
-RecursiveArrayIterator::getChildren
+MyRecursiveArrayIterator::getChildren
RecursiveArrayIteratorIterator::beginChildren(2)
RecursiveArrayIteratorIterator::callHasChildren(2) = no/yes
RecursiveArrayIteratorIterator::valid
@@ -159,19 +154,19 @@
RecursiveArrayIteratorIterator::callHasChildren(2) = no/yes
RecursiveArrayIteratorIterator::valid
RecursiveArrayIteratorIterator::next
-RecursiveArrayIterator::valid = false
+MyRecursiveArrayIterator::valid = false
RecursiveArrayIteratorIterator::endChildren(2)
-RecursiveArrayIterator::valid = false
+MyRecursiveArrayIterator::valid = false
RecursiveArrayIteratorIterator::endChildren(1)
RecursiveArrayIteratorIterator::callHasChildren(0) = yes/yes
-RecursiveArrayIterator::getChildren
+MyRecursiveArrayIterator::getChildren
RecursiveArrayIteratorIterator::beginChildren(1)
RecursiveArrayIteratorIterator::callHasChildren(1) = no/no
RecursiveArrayIteratorIterator::current
RecursiveArrayIteratorIterator::key
0=>ca
RecursiveArrayIteratorIterator::next
-RecursiveArrayIterator::valid = false
+MyRecursiveArrayIterator::valid = false
RecursiveArrayIteratorIterator::endChildren(1)
RecursiveArrayIteratorIterator::callHasChildren(0) = no/no
RecursiveArrayIteratorIterator::valid
@@ -179,7 +174,7 @@
RecursiveArrayIteratorIterator::key
3=>d
RecursiveArrayIteratorIterator::next
-RecursiveArrayIterator::valid = false
+MyRecursiveArrayIterator::valid = false
RecursiveArrayIteratorIterator::valid
-RecursiveArrayIterator::valid = false
+MyRecursiveArrayIterator::valid = false
===DONE===
http://cvs.php.net/diff.php/php-src/ext/spl/tests/iterator_022.phpt?r1=1.2&r2=1.2.2.1&ty=u
Index: php-src/ext/spl/tests/iterator_022.phpt
diff -u php-src/ext/spl/tests/iterator_022.phpt:1.2
php-src/ext/spl/tests/iterator_022.phpt:1.2.2.1
--- php-src/ext/spl/tests/iterator_022.phpt:1.2 Thu May 19 11:49:44 2005
+++ php-src/ext/spl/tests/iterator_022.phpt Sun Sep 18 13:15:04 2005
@@ -3,13 +3,8 @@
--FILE--
<?php
-class RecursiveArrayIterator extends ArrayIterator implements RecursiveIterator
+class MyRecursiveArrayIterator extends RecursiveArrayIterator
{
- function hasChildren()
- {
- return is_array($this->current());
- }
-
function getChildren()
{
echo __METHOD__ . "\n";
@@ -102,7 +97,7 @@
return NULL;
}
echo __METHOD__ . "(ok:{$this->over})\n";
- return new RecursiveArrayIterator($this->current());
+ return new MyRecursiveArrayIterator($this->current());
}
function beginChildren()
@@ -118,7 +113,7 @@
try
{
- foreach(new RecursiveArrayIteratorIterator(new
RecursiveArrayIterator(array("a", array("ba", array("bba", "bbb"),
array(array("bcaa"), array("bcba"))), array("ca"), "d")), 2) as $k=>$v)
+ foreach(new RecursiveArrayIteratorIterator(new
MyRecursiveArrayIterator(array("a", array("ba", array("bba", "bbb"),
array(array("bcaa"), array("bcba"))), array("ca"), "d")), 2) as $k=>$v)
{
if (is_array($v)) $v = join('',$v);
echo "$k=>$v\n";
@@ -166,7 +161,7 @@
RecursiveArrayIteratorIterator::key
1=>bbb
RecursiveArrayIteratorIterator::next
-RecursiveArrayIterator::valid = false
+MyRecursiveArrayIterator::valid = false
RecursiveArrayIteratorIterator::endChildren(2)
RecursiveArrayIteratorIterator::callHasChildren(1) = yes/yes
RecursiveArrayIteratorIterator::callGetChildren(ok:0)
@@ -181,9 +176,9 @@
RecursiveArrayIteratorIterator::callHasChildren(2) = no/yes
RecursiveArrayIteratorIterator::valid
RecursiveArrayIteratorIterator::next
-RecursiveArrayIterator::valid = false
+MyRecursiveArrayIterator::valid = false
RecursiveArrayIteratorIterator::endChildren(2)
-RecursiveArrayIterator::valid = false
+MyRecursiveArrayIterator::valid = false
RecursiveArrayIteratorIterator::endChildren(1)
RecursiveArrayIteratorIterator::callHasChildren(0) = yes/yes
RecursiveArrayIteratorIterator::callGetChildren(skip)
http://cvs.php.net/diff.php/php-src/ext/spl/tests/iterator_023.phpt?r1=1.1.2.1&r2=1.1.2.2&ty=u
Index: php-src/ext/spl/tests/iterator_023.phpt
diff -u php-src/ext/spl/tests/iterator_023.phpt:1.1.2.1
php-src/ext/spl/tests/iterator_023.phpt:1.1.2.2
--- php-src/ext/spl/tests/iterator_023.phpt:1.1.2.1 Wed Sep 14 23:33:04 2005
+++ php-src/ext/spl/tests/iterator_023.phpt Sun Sep 18 13:15:04 2005
@@ -3,13 +3,8 @@
--FILE--
<?php
-class RecursiveArrayIterator extends ArrayIterator implements RecursiveIterator
+class MyRecursiveArrayIterator extends RecursiveArrayIterator
{
- function hasChildren()
- {
- return is_array($this->current());
- }
-
function getChildren()
{
echo __METHOD__ . "\n";
@@ -102,7 +97,7 @@
throw new Exception("Thrown in callGetChildren()");
}
echo __METHOD__ . "(ok:{$this->over})\n";
- return new RecursiveArrayIterator($this->current());
+ return new MyRecursiveArrayIterator($this->current());
}
function beginChildren()
@@ -118,7 +113,7 @@
try
{
- foreach(new RecursiveArrayIteratorIterator(new
RecursiveArrayIterator(array("a", array("ba", array("bba", "bbb"),
array(array("bcaa"), array("bcba"))), array("ca"), "d")), 2) as $k=>$v)
+ foreach(new RecursiveArrayIteratorIterator(new
MyRecursiveArrayIterator(array("a", array("ba", array("bba", "bbb"),
array(array("bcaa"), array("bcba"))), array("ca"), "d")), 2) as $k=>$v)
{
if (is_array($v)) $v = join('',$v);
echo "$k=>$v\n";
@@ -166,7 +161,7 @@
RecursiveArrayIteratorIterator::key
1=>bbb
RecursiveArrayIteratorIterator::next
-RecursiveArrayIterator::valid = false
+MyRecursiveArrayIterator::valid = false
RecursiveArrayIteratorIterator::endChildren(2)
RecursiveArrayIteratorIterator::callHasChildren(1) = yes/yes
RecursiveArrayIteratorIterator::callGetChildren(ok:0)
@@ -181,9 +176,9 @@
RecursiveArrayIteratorIterator::callHasChildren(2) = no/yes
RecursiveArrayIteratorIterator::valid
RecursiveArrayIteratorIterator::next
-RecursiveArrayIterator::valid = false
+MyRecursiveArrayIterator::valid = false
RecursiveArrayIteratorIterator::endChildren(2)
-RecursiveArrayIterator::valid = false
+MyRecursiveArrayIterator::valid = false
RecursiveArrayIteratorIterator::endChildren(1)
RecursiveArrayIteratorIterator::callHasChildren(0) = yes/yes
RecursiveArrayIteratorIterator::callGetChildren(throw)
@@ -192,7 +187,7 @@
RecursiveArrayIteratorIterator::key
3=>d
RecursiveArrayIteratorIterator::next
-RecursiveArrayIterator::valid = false
+MyRecursiveArrayIterator::valid = false
RecursiveArrayIteratorIterator::valid
-RecursiveArrayIterator::valid = false
+MyRecursiveArrayIterator::valid = false
===DONE===
http://cvs.php.net/co.php/php-src/ext/spl/internal/recursivearrayiterator.inc?r=1.1&p=1
Index: php-src/ext/spl/internal/recursivearrayiterator.inc
+++ php-src/ext/spl/internal/recursivearrayiterator.inc
<?php
/** @file recursivearrayiterator.inc
* @ingroup Examples
* @brief class RecursiveArrayIterator
* @author Marcus Boerger
* @date 2003 - 2005
*
* SPL - Standard PHP Library
*/
/** @ingroup SPL
* @brief A recursive array iterator
* @author Marcus Boerger
* @version 1.0
* @since PHP 6.0
*
* Passes the RecursiveIterator interface to the inner Iterator and provides
* the same functionality as FilterIterator. This allows you to skip parents
* and all their childs before loading them all. You need to care about
* function getChildren() because it may not always suit your needs. The
* builtin behavior uses reflection to return a new instance of the exact same
* class it is called from. That is you extend RecursiveFilterIterator and
* getChildren() will create instance of that class. The problem is that doing
* this does not transport any state or control information of your accept()
* implementation to the new instance. To overcome this problem you might
* need to overwrite getChildren(), call this implementation and pass the
* control vaules manually.
*/
class RecursiveArrayIterator extends ArrayIterator implements RecursiveIterator
{
/** @return whether the current element has children
*/
function hasChildren()
{
return is_array($this->current());
}
/** @return an iterator for the current elements children
*
* @note the returned iterator will be of the same class as $this
*/
function getChildren()
{
if (empty($this->ref))
{
$this->ref = new ReflectionClass($this);
}
return $this->ref->newInstance($this->current());
}
private $ref;
}
?>
http://cvs.php.net/co.php/php-src/ext/spl/internal/recursivecachingiterator.inc?r=1.1&p=1
Index: php-src/ext/spl/internal/recursivecachingiterator.inc
+++ php-src/ext/spl/internal/recursivecachingiterator.inc
<?php
/** @file recursivecachingiterator.inc
* @ingroup SPL
* @brief class RecursiveCachingIterator
* @author Marcus Boerger
* @date 2003 - 2005
*
* SPL - Standard PHP Library
*/
/**
* @brief Cached recursive iteration over another Iterator
* @author Marcus Boerger
* @version 1.2
* @since PHP 5.1
*
* @see CachingIterator
*/
class RecursiveCachingIterator extends CachingIterator implements
RecursiveIterator
{
private $hasChildren;
private $getChildren;
/** Construct from another iterator
*
* @param it Iterator to cache
* @param flags Bitmask:
* - CALL_TOSTRING (whether to call __toString() for
every element)
* - CATCH_GET_CHILD (whether to catch exceptions when
trying to get childs)
*/
function __construct(RecursiveIterator $it, $flags =
self::CALL_TOSTRING)
{
parent::__construct($it, $flags);
}
/** Rewind Iterator
*/
function rewind();
{
$this->hasChildren = false;
$this->getChildren = NULL;
parent::rewind();
}
/** Forward to next element if necessary then an Iterator for the
Children
* will be created.
*/
function next()
{
if ($this->hasChildren = $this->it->hasChildren())
{
try
{
$child = $this->it->getChildren();
if (!$this->ref)
{
$this->ref = new ReflectionClass($this);
}
$this->getChildren = $ref->newInstance($child,
$this->flags);
}
catch(Exception $e)
{
if (!$this->flags & self::CATCH_GET_CHILD)
{
throw $e;
}
$this->hasChildren = false;
$this->getChildren = NULL;
}
} else
{
$this->getChildren = NULL;
}
parent::next();
}
private $ref;
/** @return whether the current element has children
* @note The check whether the Iterator for the children can be created
was
* already executed. Hence when flag CATCH_GET_CHILD was given in
* constructor this fucntion returns false so that getChildren
does
* not try to access those children.
*/
function hasChildren()
{
return $this->hasChildren;
}
/** @return An Iterator for the children
*/
function getChildren()
{
return $this->getChildren;
}
}
?>
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php