AvoidNegatedCollectionContainsOrDoesntContainRector

Convert negated calls to contains to doesntContain, or vice versa.

 use Illuminate\Support\Collection;

 $collection = new Collection([0, 1, null, -1]);
-! $collection->contains(fn (?int $number): bool => is_null($number));
-! $collection->doesntContain(fn (?int $number) => $number > 0);
+$collection->doesntContain(fn (?int $number): bool => is_null($number));
+$collection->contains(fn (?int $number) => $number > 0);

Configure your rector.php:

<?php

use RectorLaravel\Rector\BooleanNot\AvoidNegatedCollectionContainsOrDoesntContainRector;
use Rector\Config\RectorConfig;

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