Description:
------------
This code sample works fine
<?php
$input = new \ArrayObject;
$input['whatever'] = 'foo';
$array = new \ArrayObject($input);
var_dump($array['whatever']);
// will it return foo? right!
so I expected that it should work same way for objects implemented ArrayAccess
interface. But it is not true.
Test script:
---------------
https://gist.github.com/makasim/5123486
Expected result:
----------------
either YourCustomArrayObject::offsetExists or YourCustomArrayObject::offsetGet is
called
It should output 1 or 2 and exit the script
Actual result:
--------------
PHP Notice: Undefined index: whatever in /home/maksim/test.php on line 57

History

If you pass an object to ArrayObject (and it is not an ArrayObject or ArrayIterator itself), ArrayObject will work on the properties of the object.
We cannot reasonably support ArrayAccess objects, because ArrayObject requires more than this interface to provide its functionality. In particular, it would also need at least Traversable and Countable. However, even with all of these we still couldn't provide complete functionality: The sorting methods essentially require random-access iterators, a concept that doesn't even exist in PHP.