AssertSameCountOnCollectionToAssertCountRector

Change $this->assertSame(5, $collection->count()) to $this->assertCount(5, $collection) in tests

 use Doctrine\Common\Collections\Collection;

 final class SomeClass extends \PHPUnit\Framework\TestCase
 {
     private Collection $items;

     public function test(): void
     {
-        $this->assertSame(5, $this->items->count());
+        $this->assertCount(5, $this->items);
     }
 }

Configure your rector.php:

<?php

use Rector\Config\RectorConfig;
use Rector\Doctrine\TypedCollections\Rector\MethodCall\AssertSameCountOnCollectionToAssertCountRector;

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