From: Marcus Boerger Date: Fri, 8 Oct 2004 21:49:39 +0000 (+0000) Subject: - Make RecursiveFilterIterator work by using reflection X-Git-Tag: PRE_NEW_VM_GEN_PATCH~59 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1546a578ece262b838053307e08cdaca91824a50;p=php - Make RecursiveFilterIterator work by using reflection - Add docu - Add new example --- diff --git a/ext/spl/examples/nocvsdir.php b/ext/spl/examples/nocvsdir.php new file mode 100755 index 0000000000..fc0cab37d9 --- /dev/null +++ b/ext/spl/examples/nocvsdir.php @@ -0,0 +1,44 @@ + + * + * Simply specify the path to tree with parameter \. + */ + +if ($argc < 2) { + echo << + +Show the directory and all it's contents without any CVS directory in . + + The directory for which to generate the directory. + + +EOF; + exit(1); +} + +if (!class_exists("RecursiveFilterIterator")) require_once("recursivefilteriterator.inc"); + +class NoCvsDirectory extends RecursiveFilterIterator +{ + function accept() + { + return $this->getInnerIterator()->getFilename() != 'CVS'; + } +} + +$it = new RecursiveIteratorIterator(new NoCvsDirectory(new RecursiveDirectoryIterator($argv[1]))); + +foreach($it as $pathname => $file) +{ + echo $pathname."\n"; +} + +?> \ No newline at end of file diff --git a/ext/spl/examples/recursivefilteriterator.inc b/ext/spl/examples/recursivefilteriterator.inc index f97afb06d8..0c1c901fb3 100755 --- a/ext/spl/examples/recursivefilteriterator.inc +++ b/ext/spl/examples/recursivefilteriterator.inc @@ -1,8 +1,8 @@ ref = new ReflectionClass($this); parent::__construct($it); } - + + /*! return whether the inner iterator has children + */ function hasChildren() { return $this->getInnerIterator()->hasChildren(); } + /*! \return children as instance of derived RecursiveFilterIterator class + * + * \see RecursiveFilterIterator + */ function getChildren() { - return $this->getInnerIterator()->getChildren(); + return $this->ref->newInstance($this->getInnerIterator()->getChildren()); } + + private $ref; } ?> \ No newline at end of file