ForeachToArrayAllRector

Replace foreach with boolean assignment and break with array_all

-$found = true;
-foreach ($animals as $animal) {
-    if (!str_starts_with($animal, 'c')) {
-        $found = false;
-        break;
-    }
-}
+$found = array_all($animals, fn($animal) => str_starts_with($animal, 'c'));

Configure your rector.php:

<?php

use Rector\Config\RectorConfig;
use Rector\Php84\Rector\Foreach_\ForeachToArrayAllRector;

return RectorConfig::configure()
    ->withRules([
        ForeachToArrayAllRector::class,
    ]);
SETS:  PHP 8.4