Can't you just do $document = (array) $document ?