Working on updating an old app to PHP 8. I got everything running so far (at least according to the test suite) in 8.0, but when I upgrade to 8.1 I'm getting this error:
Fatal error: During inheritance of ArrayObject: Uncaught ErrorException: Return type of PropertySet::offsetGet($key) should either be compatible with ArrayObject::offsetGet(mixed $key): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
This is the method that triggers it:
class PropertySet extends ArrayObject {
// ... other methods
function offsetGet($key) {
$argc = func_num_args();
if ($this->offsetExists($key)) {
return parent::offsetGet($key);
}
else if ($argc == 2) {
return func_get_arg(1);
}
else {
throw new FException(500, "Key '$key' does not exist");
}
}
}
Since my initial google search didn't return anything with a nice, clear, actionable solution; I figured I'd post this here in case anyone has run into it (and if nothing else, once I solve it, it may help anyone who runs into this 🙂 ).