AryehGregor+php-comment at gmail dot com (09-Jan-2009 09:33)
Note that at least in PHP 5.1, objects implementing ArrayAccess cannot return objects by reference. See http://bugs.php.net/bug.php?id=34783 . If you have code like
<?php
$x = &$y[0]; ?>
then this will (as far as I can tell) *always* fail unless $y is a real array -- it cannot work if $y is an object implementing ArrayAccess. If your offsetGet() function returns by reference, you get the fatal error "Declaration of MyClass::offsetGet() must be compatible with that of ArrayAccess::offsetGet()". If you try to have it return by value, however, you get the (contradictory) fatal error "Objects used as arrays in post/pre increment/decrement must return values by reference", at least in my version of PHP.