Never open the car door like that. Never.
I have done this same maneuver who knows how many dozens of times at fast food restaurants but especially drive through bank machines. With the bank machines especially if your car is too low, or if your truck is too high you can’t read or use the machines, get your food from hand the money or credit card to the person on the other side.
The difference is that I always put the vehicle in park or and/or set the brake. With this easy precaution you won’t enc up squishing yourself by accident. I assume however that McDonalds will end up getting sued anyway.
I can’t imagine stopping @ the window and NOT putting the trans in “Park”. Most times I shut the car off.
The closest I’ve been to such an accident was when I was maybe 25(?) and my old beater Oldsmobile had “died”. I was trying to push it a bit further off the road, by myself, at the driver’s side door, managed to get a front wheel over a “bump”, but didn’t realize the overall slope was slightly downhill. I slipped as I was trying to get back in the car, and “could” have fallen underneath, but I was young and limber and more off balance than down: I managed to sort of awkwardly hop in anyway. That was a bit of a “Whew!” wake up moment.