It's important that bears don't get your food. In areas where bears aren't habituated, I think sleeping with food is often more likely to prevent conflicts than hanging it. That's because I see many, if not most, people hanging food improperly. They hang it too low, having no idea how high a bear standing on it's hind feet can reach. They hang it too close to the trunk where bears can pull it in, and so on. Hung away from camp, bears can take their time figuring out how to get at it and once they do they will watch for those opportunities again.
It is very rare indeed for a bear to try to take food out of a pack that a person is wearing. The same with a person sleeping with food where bears aren't habituated. Sleeping with food where bears are habituated is really asking for trouble and likely illegal.
It's failing to control your food that creates the habituation in my opinion. Coolers on the picnic table, unattended tents with food in them, etc. In areas where bears have learned that people mean food, then there's no question that canisters, bear boxes or hanging are the way to go.
As I mentioned, in the wild areas of Alaska with low bear populations I will stash food overnight in an air tight plastic bag, and I will put it out of sight, downwind where a bear can smell me . Out of sight, out of smell, out of mind. In most areas of Alaska bears are hunted and have no interest in approaching people.
Depends on the place, the bears, and the rules. As usual, it's risk management.