3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo implements ArrayAccess { public function offsetGet(mixed $offset) { } public function offsetExists(mixed $offset) { } public function offsetSet(mixed $offset, mixed $value) { } public function offsetUnset(mixed $offset) { } } class Foo81 implements ArrayAccess { #[\ReturnTypeWillChange] public function offsetGet(mixed $offset) { } #[\ReturnTypeWillChange] public function offsetExists(mixed $offset) { } #[\ReturnTypeWillChange] public function offsetSet(mixed $offset, mixed $value) { } #[\ReturnTypeWillChange] public function offsetUnset(mixed $offset) { } } class Foo81ForReal implements ArrayAccess { public function offsetGet(mixed $offset): string { } public function offsetExists(mixed $offset): bool { } public function offsetSet(mixed $offset, mixed $value): void { } public function offsetUnset(mixed $offset): void { } }
Output for 8.1.0 - 8.1.31, 8.2.0 - 8.2.26, 8.3.0 - 8.3.14, 8.4.1 - 8.4.2
Deprecated: Return type of Foo::offsetExists(mixed $offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/dd5Lp on line 8 Deprecated: Return type of Foo::offsetGet(mixed $offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/dd5Lp on line 4 Deprecated: Return type of Foo::offsetSet(mixed $offset, mixed $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/dd5Lp on line 12 Deprecated: Return type of Foo::offsetUnset(mixed $offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/dd5Lp on line 16
Output for 8.0.1 - 8.0.30
Output for 7.4.0 - 7.4.33
Fatal error: Declaration of Foo::offsetExists(mixed $offset) must be compatible with ArrayAccess::offsetExists($offset) in /in/dd5Lp on line 8
Process exited with code 255.

preferences:
89.26 ms | 409 KiB | 5 Q