From: Marcus Boerger Date: Sat, 8 May 2004 12:35:21 +0000 (+0000) Subject: - Docu updates X-Git-Tag: RELEASE_0_1~262 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c7b2568269b18105d4940eafe3526c5ae4ba7c54;p=php - Docu updates - Add missing example file - Fix aggregation of inner iterators in examples --- diff --git a/ext/spl/examples/appenditerator.inc b/ext/spl/examples/appenditerator.inc index df24869755..edc80410df 100755 --- a/ext/spl/examples/appenditerator.inc +++ b/ext/spl/examples/appenditerator.inc @@ -1,30 +1,40 @@ iterators = new ArrayIterator(); } - + + /** Append an Iterator + * @param $it Iterator to append + */ function append(Iterator $it) { $this->iterators->append($it); } + /** @return the current inner Iterator + */ function getInnerIterator() { return $this->iterators->current(); } + /** Rewind to the first element of the first inner Iterator. + * @return void + */ function rewind() { $this->iterators->rewind(); @@ -34,11 +44,15 @@ class AppendIterator implements Iterator } } + /** @return whether the current element is valid + */ function valid() { return $this->iterators->valid() && $this->getInnerIterator()->valid(); } + /** @return the current value if it is valid or \c NULL + */ function current() { /* Using $this->valid() would be exactly the same; it would omit @@ -48,11 +62,17 @@ class AppendIterator implements Iterator return $this->iterators->valid() ? $this->getInnerIterator()->current() : NULL; } + /** @return the current key if it is valid or \c NULL + */ function key() { return $this->iterators->valid() ? $this->getInnerIterator()->key() : NULL; } - + + /** Move to the next element. If this means to another Iterator that + * rewind that Iterator. + * @return void + */ function next() { if (!$this->iterators->valid()) @@ -75,6 +95,13 @@ class AppendIterator implements Iterator $this->iterators->next(); } } + + /** Aggregates the inner iterator + */ + function __call($func, $params) + { + return call_user_func_array(array($this->getInnerIterator(), $func), $params); + } } ?> \ No newline at end of file diff --git a/ext/spl/examples/infiniteiterator.inc b/ext/spl/examples/infiniteiterator.inc index ea83edb76e..9a3a2eca89 100755 --- a/ext/spl/examples/infiniteiterator.inc +++ b/ext/spl/examples/infiniteiterator.inc @@ -86,7 +86,7 @@ class InfiniteIterator implements Iterator */ function __call($func, $params) { - return call_user_func_array(array($this->getSubIterator(), $func), $params); + return call_user_func_array(array($this->it, $func), $params); } } diff --git a/ext/spl/examples/regexfindfile.inc b/ext/spl/examples/regexfindfile.inc new file mode 100755 index 0000000000..396a8abdfb --- /dev/null +++ b/ext/spl/examples/regexfindfile.inc @@ -0,0 +1,31 @@ +getSearch(), $this->current()); + } +} + +?> \ No newline at end of file diff --git a/ext/spl/examples/searchiterator.inc b/ext/spl/examples/searchiterator.inc index c2bbbe6dea..caee0142dd 100755 --- a/ext/spl/examples/searchiterator.inc +++ b/ext/spl/examples/searchiterator.inc @@ -42,7 +42,7 @@ abstract class SearchIterator extends FilterIterator */ function __call($func, $params) { - return call_user_func_array(array($this->getSubIterator(), $func), $params); + return call_user_func_array(array($this->getInnerIterator(), $func), $params); } }