diff options
| -rwxr-xr-x | ext/spl/examples/recursivefilteriterator.inc | 14 |
1 files changed, 9 insertions, 5 deletions
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()); } |
