<?php
class Foo implements ArrayAccess {
public function offsetGet($x) {
var_dump($x);
}
public function offsetExists($x) {
var_dump($x);
}
public function offsetSet($x, $y) {
var_dump($x);
}
public function offsetUnset($x) {
var_dump($x);
}
}
$foo = new Foo();
echo "$foo[0]";
echo "$foo[1]";
echo "$foo[00]";
Deprecated: Return type of Foo::offsetExists($x) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/qU9E9 on line 7
Deprecated: Return type of Foo::offsetGet($x) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/qU9E9 on line 4
Deprecated: Return type of Foo::offsetSet($x, $y) 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/qU9E9 on line 10
Deprecated: Return type of Foo::offsetUnset($x) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/qU9E9 on line 13
int(0)
int(1)
string(2) "00"