#48385 [Opn->Bgs]: current() on SplObjectStorage returns boolean instead of object

From: Date: Mon, 25 May 2009 17:06:20 +0000
Subject: #48385 [Opn->Bgs]: current() on SplObjectStorage returns boolean instead of object
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-137715@lists.php.net to get a copy of this message
 ID:               48385
 Updated by:       colder@php.net
 Reported By:      karsten at typo3 dot org
-Status:           Open
+Status:           Bogus
 Bug Type:         SPL related
 Operating System: *
 PHP Version:      5.3.0RC2
 New Comment:

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(); ...


Previous Comments:
------------------------------------------------------------------------

[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



Thread (3 messages)

« previous php.bugs (#137715) next »