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

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
156.9 ms | 3383 KiB | 11 Q