* @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
*/
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());
}