Skip to content

Instantly share code, notes, and snippets.

@makasim
Last active December 14, 2015 17:39
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save makasim/5123486 to your computer and use it in GitHub Desktop.
<?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