summaryrefslogtreecommitdiff
path: root/ext/spl/spl.php
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2003-08-04 23:00:57 +0000
committerMarcus Boerger <helly@php.net>2003-08-04 23:00:57 +0000
commit28dd8fcff288953bdde9b72731479b7fcb6902d2 (patch)
treedec1b426dc6f873a0e76dea5445fc04e8abb52fa /ext/spl/spl.php
parentb099670127063fd67c3d7f808e5d44f3cfb02716 (diff)
downloadphp-git-28dd8fcff288953bdde9b72731479b7fcb6902d2.tar.gz
Update documentation in source, reflection and docu itself
Diffstat (limited to 'ext/spl/spl.php')
-rwxr-xr-xext/spl/spl.php75
1 files changed, 71 insertions, 4 deletions
diff --git a/ext/spl/spl.php b/ext/spl/spl.php
index 4f664d2ffe..42380bcbda 100755
--- a/ext/spl/spl.php
+++ b/ext/spl/spl.php
@@ -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 @@ interface spl_array_read {
/*! \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 @@ interface spl_array_read {
function set($index, $value) {
$this->ar[$index] = $value;
}
+ function del($index) {
+ unset($this->ar[$index]);
+ }
}
\endcode
*/
@@ -237,7 +243,68 @@ interface spl_array_access implements spl_array_read {
/*! 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()
}
?> \ No newline at end of file