#48385 [Bgs]: current() on SplObjectStorage returns boolean instead of object
| From: | karsten at typo3 dot org | Date: | Tue, 26 May 2009 07:24:42 +0000 |
| Subject: | #48385 [Bgs]: current() on SplObjectStorage returns boolean instead of object | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-137743@lists.php.net to get a copy of this message | ||
ID: 48385
User updated by: karsten at typo3 dot org
Reported By: karsten at typo3 dot org
Status: Bogus
Bug Type: SPL related
Operating System: *
PHP Version: 5.3.0RC2
New Comment:
Thanks for the hint. Although, this is not at all intuitive! Oh,
well...
:)
Previous Comments:
------------------------------------------------------------------------
[2009-05-25 17:06:19] colder@php.net
This is expected, current/reset/key... is supposed to work on arrays,
and not on objects even if they implement the ArrayAccess interface.
Use $o->rewind(); $o->current(); ...
------------------------------------------------------------------------
[2009-05-25 14:54:15] karsten at typo3 dot org
Description:
------------
When using current on an SplObjectStorage instance I'd expect
(according
to the documentation) to get the current object back. Instead I get
back
false.
Reproduce code:
---------------
<?php
$s = new SplObjectStorage();
$o = new stdClass();
$s->attach($o);
reset($s);
var_dump(current($s));
?>
Expected result:
----------------
object(stdClass)#2 (0) {
}
Actual result:
--------------
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=48385&edit=1