this would still give a notice I think - instead I think all you need to do is cast data to an array:

` $data = (array) $data;
`