<?php
class C implements ArrayAccess {
public function offsetGet($k) {
echo "offsetGet: ";
var_dump($k);
}
public function offsetSet($k, $v) {
echo "offsetSet: ";
var_dump($k);
}
public function offsetExists($k) {
echo "offsetExists: ";
var_dump($k);
}
public function offsetUnset($k) {
echo "offsetUnset: ";
var_dump($k);
}
}
$x = new C();
function id($k) { return $k; }
var_dump($x[id('123')]);
var_dump($x[id('123')] = 4);
var_dump(isset($x[id('123')]));
unset($x[id('123')]);
Deprecated: Return type of C::offsetExists($k) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/NSY4d on line 11
Deprecated: Return type of C::offsetGet($k) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/NSY4d on line 3
Deprecated: Return type of C::offsetSet($k, $v) 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/NSY4d on line 7
Deprecated: Return type of C::offsetUnset($k) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/NSY4d on line 15
offsetGet: string(3) "123"
NULL
offsetSet: string(3) "123"
int(4)
offsetExists: string(3) "123"
bool(false)
offsetUnset: string(3) "123"