#33015 [Asn->Csd]: ArrayObject: object- and array-access not interchangeable
| From: | helly@php.net | Date: | Mon, 20 Jun 2005 20:54:02 +0000 |
| Subject: | #33015 [Asn->Csd]: ArrayObject: object- and array-access not interchangeable | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-80726@lists.php.net to get a copy of this message | ||
ID: 33015
Updated by: helly@php.net
Reported By: pecoes at xs4all dot nl
-Status: Assigned
+Status: Closed
Bug Type: SPL related
Operating System: *
-PHP Version: 5.*
+PHP Version: 5.0.*
Assigned To: helly
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Implemented through setFlags() / getFlags(). Note that you can set
control flags in the constructor already.
Previous Comments:
------------------------------------------------------------------------
[2005-05-17 23:04:41] pecoes at xs4all dot nl
Turns out the work-around is not terribly complicated:
class ArrayObject2 extends ArrayObject
{
function __set($prop, $val)
{
parent::offsetSet($prop, $val);
}
function __get($prop)
{
return parent::offsetGet($prop);
}
}
Could you turn that into the default behaviour?
------------------------------------------------------------------------
[2005-05-17 15:58:41] pecoes at xs4all dot nl
The problem is not in the constructor, is it? __get should return
array-values as well and every offsetGet should return property-values
as well.
------------------------------------------------------------------------
[2005-05-17 15:54:43] pecoes at xs4all dot nl
What would "exchangeArray" do?
------------------------------------------------------------------------
[2005-05-17 15:37:43] helly@php.net
Yep it's me alone. I'll do something as soon as i find ime then. How
about some exchangeArray() method that drops the current array and
replaces it with the given one. So the following would do what you
want:
class ArrayObjectEx extends ArrayObject
{
function __construct()
{
$this->exchangeArray($this);
}
}
$obj = new ArrayObjectEx;
------------------------------------------------------------------------
[2005-05-17 13:42:33] pecoes at xs4all dot nl
Thanks for the offer, but I'm not in need of a work-around. IMHO it
would be great to have a "simple" solution - "simple" from a user's
perspective :)
You've created some pretty fascinating stuff with the SPL and from the
looks of it, you're doing this all alone right now, so I really don't
want to rush you... Just tell me how big the chances are in the long
run!
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/33015
--
Edit this bug report at http://bugs.php.net/?id=33015&edit=1