helly Mon Aug 4 19:00:58 2003 EDT
Modified files:
/spl spl.php spl_array.c spl_functions.h
Log:
Update documentation in source, reflection and docu itself
Index: spl/spl.php
diff -u spl/spl.php:1.6 spl/spl.php:1.7
--- spl/spl.php:1.6 Sun Jul 20 08:30:05 2003
+++ spl/spl.php Mon Aug 4 19:00:57 2003
@@ -11,13 +11,16 @@
* the input parameter to foreach() calls which would normally be an
* array.
*
- * The only thing a class has to do is
+ * The class must implement the function new_iterator which must return
+ * an object which implements the interface spl_forward.
+ *
+ * \see spl_forward, spl_sequence, spl_forward_assoc, spl_sequence_assoc
*/
interface spl_iterator {
/*! \brief Create a new iterator
*
- * used for example in foreach() operator.
+ * \return an object that implements the interface spl_forward.
*/
function new_iterator();
}
@@ -217,7 +220,7 @@
/*! \brief array read/write access for objects.
*
- * The following example shows how to use an array_writer:
+ * The following example shows how to use interface array_access:
* \code
class array_emulation implemets spl_array_access {
private $ar = array();
@@ -230,6 +233,9 @@
function set($index, $value) {
$this->ar[$index] = $value;
}
+ function del($index) {
+ unset($this->ar[$index]);
+ }
}
\endcode
*/
@@ -237,7 +243,68 @@
/*! Set the value identified by $index to $value.
*/
- function set($value, $index);
+ function set($index, $value);
+
+ /*! Delete (unset) the value identified by $index.
+ */
+ function del($index);
+}
+
+/*! \brief An array wrapper
+ *
+ * This array wrapper allows to recursively iterate over Arrays and Objects.
+ *
+ * \see spl_array_it
+ */
+class spl_array implements spl_iterator {
+
+ /*! Construct a new array iterator from anything that has a hash table.
+ * That is any Array or Object.
+ *
+ * \param $array the array to use.
+ */
+ function __construct($array);
+
+ /*! \copydoc spl_iterator::new_iterator
+ */
+ function new_iterator();
+}
+
+/*! \brief An array iterator
+ *
+ * This iterator allows to unset and modify values and keys while iterating
+ * over Arrays and Objects.
+ *
+ * To use this class you must instanciate spl_array.
+ */
+class spl_array_it implements spl_sequence_assoc {
+
+ /*! Construct a new array iterator from anything that has a hash table.
+ * That is any Array or Object.
+ *
+ * \param $array the array to use.
+ */
+ private function __construct($array)
+
+ /*! \copydoc spl_sequence::rewind
+ */
+ function rewind()
+
+ /*! \copydoc spl_forward::current
+ */
+ function current()
+
+ /*! \copydoc spl_assoc::key
+ */
+ function key()
+
+ /*! \copydoc spl_forward::next
+ */
+ function next()
+
+ /*! \copydoc spl_forward::has_more
+ */
+ function has_more()
}
?>
Index: spl/spl_array.c
diff -u spl/spl_array.c:1.14 spl/spl_array.c:1.15
--- spl/spl_array.c:1.14 Mon Aug 4 17:56:05 2003
+++ spl/spl_array.c Mon Aug 4 19:00:57 2003
@@ -308,19 +308,24 @@
SPL_CLASS_FUNCTION(array, next);
SPL_CLASS_FUNCTION(array, has_more);
+static
+ZEND_BEGIN_ARG_INFO(arginfo_array___construct, 0)
+ ZEND_ARG_INFO(0, array)
+ZEND_END_ARG_INFO();
+
static zend_function_entry spl_array_class_functions[] = {
- SPL_CLASS_FE(array, __construct, NULL)
- SPL_CLASS_FE(array, new_iterator, NULL)
+ SPL_CLASS_FE(array, __construct, arginfo_array___construct, ZEND_ACC_PUBLIC)
+ SPL_CLASS_FE(array, new_iterator, NULL, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
};
static zend_function_entry spl_array_it_class_functions[] = {
- SPL_CLASS_FE(array, __construct, NULL)
- SPL_CLASS_FE(array, rewind, NULL)
- SPL_CLASS_FE(array, current, NULL)
- SPL_CLASS_FE(array, key, NULL)
- SPL_CLASS_FE(array, next, NULL)
- SPL_CLASS_FE(array, has_more, NULL)
+ SPL_CLASS_FE(array, __construct, arginfo_array___construct, ZEND_ACC_PRIVATE)
+ SPL_CLASS_FE(array, rewind, NULL, ZEND_ACC_PUBLIC)
+ SPL_CLASS_FE(array, current, NULL, ZEND_ACC_PUBLIC)
+ SPL_CLASS_FE(array, key, NULL, ZEND_ACC_PUBLIC)
+ SPL_CLASS_FE(array, next, NULL, ZEND_ACC_PUBLIC)
+ SPL_CLASS_FE(array, has_more, NULL, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
};
@@ -558,8 +563,8 @@
}
/* }}} */
-/* {{{ proto void spl_array::__construct(array ar = array())
- proto void spl_array_it::__construct(array ar = array())
+/* {{{ proto void spl_array::__construct(array|object ar = array())
+ proto void spl_array_it::__construct(array|object ar = array())
Cronstructs a new array iterator from a path. */
SPL_CLASS_FUNCTION(array, __construct)
{
Index: spl/spl_functions.h
diff -u spl/spl_functions.h:1.7 spl/spl_functions.h:1.8
--- spl/spl_functions.h:1.7 Sun Aug 3 18:29:20 2003
+++ spl/spl_functions.h Mon Aug 4 19:00:57 2003
@@ -59,8 +59,8 @@
void spl_add_interfaces(zval * list, zend_class_entry * pce TSRMLS_DC);
int spl_add_classes(zend_class_entry ** ppce, zval *list TSRMLS_DC);
-#define SPL_CLASS_FE(class_name, function_name, arg_types) \
- PHP_NAMED_FE( function_name, spl_ ## class_name ## _ ## function_name,
arg_types)
+#define SPL_CLASS_FE(class_name, function_name, arg_info, flags) \
+ { #function_name, spl_ ## class_name ## _ ## function_name, arg_info,
sizeof(arg_info)/sizeof(struct _zend_arg_info)-1, flags },
#define SPL_CLASS_FUNCTION(class_name, function_name) \
PHP_NAMED_FUNCTION(spl_ ## class_name ## _ ## function_name)
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php