rectorphp/rector-doctrine

New rule for iterate() => toIterable() since 2.8.x

johanadivare opened this issue · 2 comments

With doctrine/orm#7885 & doctrine/orm#8293 there was a new function introduced to loop.

Add a rule the will move all iterate() to toIterable(). And make sure we fix cases like:

-$results = $em->select('e')->from('entity')->getQuery()->iterate();
+$results = $em->select('e')->from('entity')->getQuery()->toIterable();
foreach($resuls as $result) {
-   $entityIsHere = $result[0];
+   $entityIsHere = $result;
}

Also create a doctrine-orm-28.php

Hi @johanadivare ,

this seems like straightfoward rule. Could you send PR for it?

I think to replace the function is pretty straight forward but then seeing where the output is used and to change accordingly is more difficult, i could work on a draft and see how far i come