Arquivos
hhvm/hphp/test/vm/zend_indirect_method_call_005.php
T
2013-03-05 22:07:56 -08:00

37 linhas
970 B
PHP

<?php
/*
We dont' have ArrayObject so use something from http://php.net/manual/en/class.arrayaccess.php
class foo extends ArrayObject {
public function __construct($arr) {
parent::__construct($arr);
}
}
*/
class foo implements arrayaccess {
private $container = array();
public function __construct($container) {
$this->container = $container;
}
public function offsetSet($offset, $value) {
if (is_null($offset)) {
$this->container[] = $value;
} else {
$this->container[$offset] = $value;
}
}
public function offsetExists($offset) {
return isset($this->container[$offset]);
}
public function offsetUnset($offset) {
unset($this->container[$offset]);
}
public function offsetGet($offset) {
return isset($this->container[$offset]) ? $this->container[$offset] : null;
}
}
var_dump( (new foo( array(1, array(4, 5), 3) ))[1][0] ); // int(4)
?>