Run Rector on your code to see what it can do for you:

 <div>
-    <?php for ($i = 5; $i <= count($items); $i++) : ?>
+    
+$counter = count($items);<?php for ($i = 5; $i <= $counter; $i++) : ?>
         <p>Item <?php echo $i; ?></p>
     <?php endfor; ?>
-</div>
+</div>
PHP snippet to change

Applied Rules:

Not a change you expect?

Config  rector.php
Rector version: 6d8bee - released at 2026-05-04 23:43