DowngradeIteratorCountToArrayRector

Ensure pass Traversable instance before use in iterator_count() and iterator_to_array()

 function test(array|Traversable $data) {
-    $c = iterator_count($data);
-    $v = iterator_to_array($data);
+    $c = iterator_count(is_array($data) ? new ArrayIterator($data) : $data);
+    $v = iterator_to_array(is_array($data) ? new ArrayIterator($data) : $data);
 }

Configure your rector.php:

<?php

use Rector\Config\RectorConfig;
use Rector\DowngradePhp82\Rector\FuncCall\DowngradeIteratorCountToArrayRector;

return RectorConfig::configure()
    ->withRules([
        DowngradeIteratorCountToArrayRector::class,
    ]);