Created
January 13, 2015 14:02
-
-
Save mageekguy/101480a32660c4860bb6 to your computer and use it in GitHub Desktop.
ArrayAccess and "undefined" key
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 | |
class foo implements arrayAccess | |
{ | |
public $values; | |
function offsetSet($key, $value) | |
{ | |
var_dump($key); | |
$this->values[$key ?: sizeof($this->values)] = $value; | |
} | |
function offsetGet($key) | |
{ | |
} | |
function offsetExists($key) | |
{ | |
} | |
function offsetUnset($key) | |
{ | |
} | |
} | |
$foo = new foo; | |
$foo[] = 'bar'; | |
var_dump($foo->values); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment