diff options
author | Marcus Boerger <helly@php.net> | 2005-10-03 16:05:08 +0000 |
---|---|---|
committer | Marcus Boerger <helly@php.net> | 2005-10-03 16:05:08 +0000 |
commit | 308a64bc08a9c1f39619e83d9d6c502dd3edfdb8 (patch) | |
tree | 1d34ac7d2c66607aed6f58dfe1d60630ed422087 /ext/spl/internal | |
parent | 42728f947c0ced85812439b24159d5a0b75594b5 (diff) | |
download | php-git-308a64bc08a9c1f39619e83d9d6c502dd3edfdb8.tar.gz |
- MFH Really allow SXE being shared by not using anything from it directly in SPL
Diffstat (limited to 'ext/spl/internal')
-rwxr-xr-x | ext/spl/internal/cachingiterator.inc | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/ext/spl/internal/cachingiterator.inc b/ext/spl/internal/cachingiterator.inc index f5ca2c3c9d..6391322c3d 100755 --- a/ext/spl/internal/cachingiterator.inc +++ b/ext/spl/internal/cachingiterator.inc @@ -27,8 +27,10 @@ */ class CachingIterator implements OuterIterator { - const CALL_TOSTRING = 1; - const CATCH_GET_CHILD = 2; + const CALL_TOSTRING = 1; + const CATCH_GET_CHILD = 2; + const TOSTRING_USE_KEY = 4; + const TOSTRING_USE_CURRENT = 8; private $it; private $current; @@ -44,8 +46,13 @@ class CachingIterator implements OuterIterator */ function __construct(Iterator $it, $flags = self::CALL_TOSTRING) { + if ((($flags & self::CALL_TOSTRING) && ($flags & (self::TOSTRING_USE_KEY|self::TOSTRING_USE_CURRENT))) + || ((flags & (self::CIT_TOSTRING_USE_KEY|self::CIT_TOSTRING_USE_CURRENT)) == (self::CIT_TOSTRING_USE_KEY|self::CIT_TOSTRING_USE_CURRENT))) + { + throw new InvalidArgumentException('Flags must contain only one of CIT_CALL_TOSTRING, CIT_TOSTRING_USE_KEY, CIT_TOSTRING_USE_CURRENT'); + } $this->it = $it; - $this->flags = $flags & (self::CALL_TOSTRING|self::CATCH_GET_CHILD); + $this->flags = $flags & (0x0000FFFF); $this->next(); } @@ -123,7 +130,16 @@ class CachingIterator implements OuterIterator */ function __toString() { - if (!$this->flags & self::CALL_TOSTRING) { + if ($this->flags & self::TOSTRING_USE_KEY) + { + return $this->key; + } + else if ($this->flags & self::TOSTRING_USE_CURRENT) + { + return $this->current; + } + if (!$this->flags & self::CALL_TOSTRING) + { throw new exception('CachingIterator does not fetch string value (see CachingIterator::__construct)'); } return $this->strValue; |