<?php
class test implements ArrayAccess {
protected $_array = array();
public function offsetGet($name) {
return $this->_array[$name];
}
public function offsetSet($name,$value) {
$this->_array[$name] = $value;
}
public function offsetUnset($name) {
unset($this->_array[$name]);
}
public function offsetExists($name) {
return isset($this->_array[$name]);
}
}
$test = new test();
$test['foo'] = 'bar';
$test['baz'] = array('test','validator');
var_dump($test);
Deprecated: Return type of test::offsetExists($name) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/ICQQG on line 13
Deprecated: Return type of test::offsetGet($name) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/ICQQG on line 4
Deprecated: Return type of test::offsetSet($name, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/ICQQG on line 7
Deprecated: Return type of test::offsetUnset($name) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/ICQQG on line 10
object(test)#1 (1) {
["_array":protected]=>
array(2) {
["foo"]=>
string(3) "bar"
["baz"]=>
array(2) {
[0]=>
string(4) "test"
[1]=>
string(9) "validator"
}
}
}