Skip to content

Instantly share code, notes, and snippets.

@ad3n
Created July 4, 2019 13:04
Show Gist options
  • Save ad3n/4c5f2a94fad78feb39902f4e9ab66e58 to your computer and use it in GitHub Desktop.
Save ad3n/4c5f2a94fad78feb39902f4e9ab66e58 to your computer and use it in GitHub Desktop.
class TArrayAccess implements \ArrayAccess
{
private $arr;
public function offsetExists($offset)
{
return isset($this->arr[$offset]);
}
public function offsetGet($offset)
{
return $this->arr[$offset];
}
public function offsetSet($offset, $value)
{
$this->arr[$offset] = &$value;
}
public function offsetUnset($offset)
{
unset($this->arr[$offset]);
}
}
$a = new TArrayAccess();
$b = 10;
$a['a'] = $b;
$b = 20;
var_dump($a['a']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment