#34445 [Opn->Bgs]: ArrayAccess implementation class cannot be "foreach"-ed
| From: | johannes@php.net | Date: | Fri, 09 Sep 2005 18:34:32 +0000 |
| Subject: | #34445 [Opn->Bgs]: ArrayAccess implementation class cannot be "foreach"-ed | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-84807@lists.php.net to get a copy of this message | ||
ID: 34445
Updated by: johannes@php.net
Reported By: stochnagara at hotmail dot com
-Status: Open
+Status: Bogus
Bug Type: Class/Object related
PHP Version: 5CVS-2005-09-09 (snap)
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
ArrayAccess is no Iterator
Previous Comments:
------------------------------------------------------------------------
[2005-09-09 20:30:22] stochnagara at hotmail dot com
Description:
------------
I made a class which implements ArrayAccess. Then I try to use foreach
on one of its array values and I get error "Objects used as arrays in
post/pre increment/decrement must return values by reference"
I've reduced the big code fragment to this small one:
Reproduce code:
---------------
<?
class foo implements ArrayAccess {
protected $params;
public function offsetGet ($field) { return $this->params[$field]; }
public function offsetExists ($field) { return isset
($this->params[$field]); }
public function offsetUnset ($field) { unset ($this->params[$field]);
}
public function offsetSet ($field, $value) { $this->params[$field] =
$value; }
}
$foo = new foo;
foreach ($foo['options'] as $optionvalue => $optiontext) {}
Expected result:
----------------
no errors
Actual result:
--------------
Fatal error: Objects used as arrays in post/pre increment/decrement
must return values by reference in ... on line 161
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=34445&edit=1