3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @template-implements ArrayAccess<int, string> */ class C implements ArrayAccess { /** * @param int $offset * @return bool */ public function offsetExists($offset) { return true; } /** * @param int $offset * @return string */ public function offsetGet($offset) { return "";} /** * @param ?int $offset * @return void */ public function offsetSet($offset, $value) { /** @psalm-suppress ForbiddenCode */ var_dump(__METHOD__, array("offset" => $offset, "value" => $value)); } /** * @param int $offset * @return void */ public function offsetUnset($offset) { } } $q = new C; $q[] = '123'; // should only be forbidden when offsetSet does not accept null as its first parameter
Output for rfc.property-hooks, git.master, git.master_jit
Deprecated: Return type of C::offsetExists($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/uVUXY on line 10 Deprecated: Return type of C::offsetGet($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/uVUXY on line 16 Deprecated: Return type of C::offsetSet($offset, $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/uVUXY on line 22 Deprecated: Return type of C::offsetUnset($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/uVUXY on line 31 string(12) "C::offsetSet" array(2) { ["offset"]=> NULL ["value"]=> string(3) "123" }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
46.63 ms | 2740 KiB | 4 Q