I don't find a reason why the offset is considered illegal in the code snippet. Any suggestion to fix this with an explanation why the error occurs is greatly appreciated.
foreach ($my_return->refund_items as $key => $my_refund_item) {
$refund_item_info = $my_return->get_line_item_info($my_refund_item['lineitem_fk']);
if ($refund_item_info['order_fk'] != 0)
$my_refund_item['sku'] = $refund_item_info['sku'];
$refund_items_array[] = $my_refund_item;
}