Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
$input = new \ArrayObject;
$input['whatever'] = 'foo';
$array = new \ArrayObject($input);
var_dump($array['whatever']);
// will it return foo? right!
//but what about your custom ArrayObject?
class YourCustomArrayObject implements \ArrayAccess, \IteratorAggregate
{
public function offsetExists($offset)
{
var_dump(1);
die;
}
public function offsetGet($offset)
{
var_dump(2);
die;
}
public function offsetSet($offset, $value)
{
var_dump(3);
die;
}
public function offsetUnset($offset)
{
var_dump(4);
die;
}
public function __get($name)
{
var_dump(5);
die;
}
public function __call($name, $args)
{
var_dump(6);
die;
}
public function getIterator()
{
var_dump(7);
die;
}
}
$bar = new \ArrayObject(new YourCustomArrayObject);
$bar['whatever'];
//which result do you expect here?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.