diff options
Diffstat (limited to 'ext/spl/internal/splobjectstorage.inc')
| -rwxr-xr-x | ext/spl/internal/splobjectstorage.inc | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/ext/spl/internal/splobjectstorage.inc b/ext/spl/internal/splobjectstorage.inc index 278e64151d..c7a56b43e1 100755 --- a/ext/spl/internal/splobjectstorage.inc +++ b/ext/spl/internal/splobjectstorage.inc @@ -4,7 +4,7 @@ * @ingroup SPL * @brief class SplObjectStorage * @author Marcus Boerger - * @date 2003 - 2005 + * @date 2003 - 2008 * * SPL - Standard PHP Library */ @@ -12,7 +12,7 @@ /** * @brief Object storage * @author Marcus Boerger - * @version 1.0 + * @version 1.1 * @since PHP 5.1.2 * * This container allows to store objects uniquly without the need to compare @@ -50,7 +50,27 @@ class SplObjectStorage implements Iterator, Countable */ function current() { - return current($this->storage); + $element = current($this->storage); + return $element ? $element[0] : NULL + } + + /** @return get current object's associated information + * @since 5.3.0 + */ + function getInfo() + { + $element = current($this->storage); + return $element ? $element[1] : NULL + } + + /** @return set current object's associated information + * @since 5.3.0 + */ + function setInfo($inf = NULL) + { + if ($this->valid()) { + $this->storage[$this->index][1] = $inf; + } } /** Forward to next element @@ -75,9 +95,9 @@ class SplObjectStorage implements Iterator, Countable { if (is_object($obj)) { - foreach($this->storage as $object) + foreach($this->storage as $element) { - if ($object === $obj) + if ($object === $element[0]) { return true; } @@ -88,11 +108,11 @@ class SplObjectStorage implements Iterator, Countable /** @param $obj new object to attach to storage if not yet contained */ - function attach($obj) + function attach($obj, $inf = NULL) { if (is_object($obj) && !$this->contains($obj)) { - $this->storage[] = $obj; + $this->storage[] = array($obj, $inf); } } @@ -102,9 +122,9 @@ class SplObjectStorage implements Iterator, Countable { if (is_object($obj)) { - foreach($this->storage as $idx => $object) + foreach($this->storage as $idx => $element) { - if ($object === $obj) + if ($object === $element[0]) { unset($this->storage[$idx]); $this->rewind(); |
