summaryrefslogtreecommitdiff
path: root/ext/spl/examples
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2005-10-08 19:09:58 +0000
committerMarcus Boerger <helly@php.net>2005-10-08 19:09:58 +0000
commit11f0ff9c1afece2127ef7c0fc2e9f6b3f5b46d15 (patch)
treeef83e26da6b1cf822f8f28828cbe92192edd619c /ext/spl/examples
parent7357ac0b968bb338bddfc47ae6ffe51e012f41e7 (diff)
downloadphp-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-xext/spl/examples/class_tree.php1
-rwxr-xr-xext/spl/examples/recursivetreeiterator.inc25
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