diff options
| author | Marcus Boerger <helly@php.net> | 2005-10-08 19:09:58 +0000 |
|---|---|---|
| committer | Marcus Boerger <helly@php.net> | 2005-10-08 19:09:58 +0000 |
| commit | 11f0ff9c1afece2127ef7c0fc2e9f6b3f5b46d15 (patch) | |
| tree | ef83e26da6b1cf822f8f28828cbe92192edd619c /ext/spl/examples | |
| parent | 7357ac0b968bb338bddfc47ae6ffe51e012f41e7 (diff) | |
| download | php-git-11f0ff9c1afece2127ef7c0fc2e9f6b3f5b46d15.tar.gz | |
- Update docu
- Synch class consts with HEAD
- Synch example RecursiveTreeIterator (as far as possible)
Diffstat (limited to 'ext/spl/examples')
| -rwxr-xr-x | ext/spl/examples/class_tree.php | 1 | ||||
| -rwxr-xr-x | ext/spl/examples/recursivetreeiterator.inc | 25 |
2 files changed, 23 insertions, 3 deletions
diff --git a/ext/spl/examples/class_tree.php b/ext/spl/examples/class_tree.php index 07741a7dd8..a3083280be 100755 --- a/ext/spl/examples/class_tree.php +++ b/ext/spl/examples/class_tree.php @@ -5,6 +5,7 @@ * @ingroup Examples * @author Marcus Boerger * @date 2003 - 2005 + * @version 1.0 * * Usage: php class_tree.php \<class\> * diff --git a/ext/spl/examples/recursivetreeiterator.inc b/ext/spl/examples/recursivetreeiterator.inc index 62198c8d36..ea3cb6ea7f 100755 --- a/ext/spl/examples/recursivetreeiterator.inc +++ b/ext/spl/examples/recursivetreeiterator.inc @@ -18,16 +18,21 @@ */ class RecursiveTreeIterator extends RecursiveIteratorIterator { + const BYPASS_CURRENT = 0x00000004; + private $callToString; + private $rit_flags; /** * @param it iterator to use as inner iterator - * @param flags flags passed to RecursiveIteratoIterator (parent) + * @param rit_flags flags passed to RecursiveIteratoIterator (parent) * @param cit_flags flags passed to RecursiveCachingIterator (for hasNext) + * @param mode mode passed to RecursiveIteratoIterator (parent) */ - function __construct(RecursiveIterator $it, $flags = self::SELF_FIRST, $cit_flags = CachingIterator::CATCH_GET_CHILD) + function __construct(RecursiveIterator $it, $rit_flags = 0, $cit_flags = CachingIterator::CATCH_GET_CHILD, $mode = self::SELF_FIRST) { - parent::__construct(new RecursiveCachingIterator($it, $cit_flags), $flags); + parent::__construct(new RecursiveCachingIterator($it, $cit_flags), $mode, $rit_flags); + $this->rit_flags = $rit_flags; $this->callToString = (bool)($cit_flags & CachingIterator::CALL_TOSTRING); } @@ -74,7 +79,21 @@ class RecursiveTreeIterator extends RecursiveIteratorIterator */ function current() { + if ($this->rit_flags & self::BYPASS_CURRENT) + { + return parent::current(); + } + else + { return $this->getPrefix() . $this->getEntry() . $this->getPostfix(); + } + } + + /** @return the current key prefixed and postfixed + */ + function key() + { + return $this->getPrefix() . parent::key() . $this->getPostfix(); } /** Aggregates the inner iterator |
