3v4l.org

run code in 300+ PHP versions simultaneously
<?php class GlobalArrayWrapper implements ArrayAccess { protected $values = []; public function __construct(array $values) { $this->values = $values; } /** * {@inheritdoc} */ public function offsetExists($offset) { trigger_error('You are doing it wrong', E_USER_DEPRECATED); return isset($this->values[$offset]); } /** * {@inheritdoc} */ public function offsetGet($offset) { trigger_error('You are doing it wrong', E_USER_DEPRECATED); return $this->values[$offset] ?? NULL; } /** * {@inheritdoc} */ public function offsetSet($offset, $value) { trigger_error('You are doing it wrong', E_USER_DEPRECATED); return $this->values[$offset] = $value; } /** * {@inheritdoc} */ public function offsetUnset($offset) { trigger_error('You are doing it wrong', E_USER_DEPRECATED); unset($this->values[$offset]); } } $GLOBALS['pager_page_array'] = [1, 2]; $GLOBALS['pager_page_array'] = new GlobalArrayWrapper($GLOBALS['pager_page_array']); echo $GLOBALS['pager_page_array'][0];
Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
Deprecated: Return type of GlobalArrayWrapper::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/AlHZK on line 11 Deprecated: Return type of GlobalArrayWrapper::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/AlHZK on line 19 Deprecated: Return type of GlobalArrayWrapper::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/AlHZK on line 27 Deprecated: Return type of GlobalArrayWrapper::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/AlHZK on line 35 Deprecated: You are doing it wrong in /in/AlHZK on line 20 1
Output for 7.1.25 - 7.1.32, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
Deprecated: You are doing it wrong in /in/AlHZK on line 20 1

preferences:
144.53 ms | 409 KiB | 5 Q