Convert toArray()
to all()
when the collection does not contain any Arrayable objects.
use Illuminate\Support\Collection;
-new Collection([0, 1, -1])->toArray();
+new Collection([0, 1, -1])->all();
Configure your rector.php
:
<?php
use RectorLaravel\Rector\MethodCall\ConvertEnumerableToArrayToAllRector;
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withRules([
ConvertEnumerableToArrayToAllRector::class,
]);