cvs: php-src /ext/spl/examples recursivefilteriterator.inc /ext/spl/internal recursivefilteriterator.inc

From: Date: Fri, 02 Sep 2005 19:15:31 +0000
Subject: cvs: php-src /ext/spl/examples recursivefilteriterator.inc /ext/spl/internal recursivefilteriterator.inc
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-33780@lists.php.net to get a copy of this message
helly Fri Sep 2 15:15:31 2005 EDT Removed files: /php-src/ext/spl/examples recursivefilteriterator.inc Modified files: /php-src/ext/spl/internal recursivefilteriterator.inc Log: - Update docu http://cvs.php.net/diff.php/php-src/ext/spl/internal/recursivefilteriterator.inc?r1=1.1&r2=1.2&ty=u Index: php-src/ext/spl/internal/recursivefilteriterator.inc diff -u php-src/ext/spl/internal/recursivefilteriterator.inc:1.1 php-src/ext/spl/internal/recursivefilteriterator.inc:1.2 --- php-src/ext/spl/internal/recursivefilteriterator.inc:1.1 Wed Aug 10 15:48:48 2005 +++ php-src/ext/spl/internal/recursivefilteriterator.inc Fri Sep 2 15:15:30 2005 @@ -1,32 +1,39 @@ <?php -/** @file recursivefilteriterator.inc - * @ingroup SPL - * @brief class RecursiveFilterIterator - * @author Marcus Boerger - * @date 2003 - 2005 - * - * SPL - Standard PHP Library - */ - +/** @file recursivefilteriterator.inc + * @ingroup SPL + * @brief class RecursiveFilterIterator + * @author Marcus Boerger + * @date 2003 - 2005 + * + * SPL - Standard PHP Library + */ + /** * @brief Iterator to filter recursive iterators * @author Marcus Boerger * @version 1.0 * @since PHP 6.0 * - * This extended FilterIterator allows a recursive iteration using - * RecursiveIteratorIterator that only shows those elements which - * are accepted. It is of course better to filter before doing the - * recursion since it allows to prevent recursion into children that - * get declined later anyway. + * Passes the RecursiveIterator interface to the inner Iterator and provides + * the same functionality as FilterIterator. This allows you to skip parents + * and all their childs before loading them all. You need to care about + * function getChildren() because it may not always suit your needs. The + * builtin behavior uses reflection to return a new instance of the exact same + * class it is called from. That is you extend RecursiveFilterIterator and + * getChildren() will create instance of that class. The problem is that doing + * this does not transport any state or control information of your accept() + * implementation to the new instance. To overcome this problem you might + * need to overwrite getChildren(), call this implementation and pass the + * control vaules manually. */ -class RecursiveFilterIterator extends FilterIterator implements RecursiveIterator +abstract class RecursiveFilterIterator extends FilterIterator implements RecursiveIterator { /** @param $it the RecursiveIterator to filter */ function __construct(RecursiveIterator $it) { + $this->ref = new ReflectionClass($this); parent::__construct($it); } @@ -34,15 +41,17 @@ */ function hasChildren() { - return $this->it->hasChildren(); + return $this->getInnerIterator()->hasChildren(); } /** @return the ParentIterator for the current elements children */ function getChildren() { - return new RecursiveFilterIterator($this->it->getChildren()); + return $this->ref->newInstance($this->getInnerIterator()->getChildren()); } + + private $ref; } ?> \ No newline at end of file

« previous php.cvs (#33780) next »