This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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