From 1546a578ece262b838053307e08cdaca91824a50 Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Fri, 8 Oct 2004 21:49:39 +0000 Subject: [PATCH] - Make RecursiveFilterIterator work by using reflection - Add docu - Add new example --- ext/spl/examples/nocvsdir.php | 44 ++++++++++++++++++++ ext/spl/examples/recursivefilteriterator.inc | 30 +++++++++++-- 2 files changed, 70 insertions(+), 4 deletions(-) create mode 100755 ext/spl/examples/nocvsdir.php 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 -- 2.50.1