Rector has an automated fix ('ListEachRector') to migrate away from `each()`:
https://github.com/rectorphp/rector/blob/master/docs/AllRectorsOverview.md#listeachrector
If you look at the code example you'll see this is even quite simple to do by hand.