From: Marcus Boerger Date: Sun, 4 Sep 2005 18:55:03 +0000 (+0000) Subject: - MFH X-Git-Tag: php-5.1.0RC2_PRE~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=222900c4b0a19a07776f042e2618a744d5e55f64;p=php - MFH --- diff --git a/ext/spl/examples/recursivefilteriterator.inc b/ext/spl/examples/recursivefilteriterator.inc index 44e1bbcb99..f78abe8a52 100755 --- a/ext/spl/examples/recursivefilteriterator.inc +++ b/ext/spl/examples/recursivefilteriterator.inc @@ -13,6 +13,7 @@ * @brief A recursive Filter * @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 @@ -28,27 +29,30 @@ */ abstract class RecursiveFilterIterator extends FilterIterator implements RecursiveIterator { - /*! The constructor takes a RecursiveIterator + /** @param $it the RecursiveIterator to filter */ function __construct(RecursiveIterator $it) { - $this->ref = new ReflectionClass($this); parent::__construct($it); } - /*! return whether the inner iterator has children + /** @return whether the current element has children */ function hasChildren() { return $this->getInnerIterator()->hasChildren(); } - /*! \return children as instance of derived RecursiveFilterIterator class + /** @return an iterator for the current elements children * - * \see RecursiveFilterIterator + * @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->getInnerIterator()->getChildren()); }