<?php
class ObjArray implements ArrayAccess
{
private $data;
public function offsetSet($key, $value)
{
var_dump($key, $value);
$this->data[$key] = $value;
}
public function offsetGet($key)
{
return $this->data[$key];
}
public function offsetUnset($key)
{
unset($this->data[$key]);
}
public function offsetExists($key)
{
return isset($this->data[$key]);
}
}
$arr = new ObjArray;
$arr[0] = 1;
$arr[] = 2;
Deprecated: Return type of ObjArray::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/1rIlB on line 23
Deprecated: Return type of ObjArray::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/1rIlB on line 13
Deprecated: Return type of ObjArray::offsetSet($key, $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/1rIlB on line 7
Deprecated: Return type of ObjArray::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/1rIlB on line 18
int(0)
int(1)
NULL
int(2)