AllowMockObjectsForDataProviderRector

Add #[AllowMockObjectsWithoutExpectations] attribute to PHPUnit test classes that have methods with data providers and mock objects without expectations

 use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;

+#[\PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations]
 final class SomeClass extends TestCase
 {
     #[DataProvider('someDataProvider')]
     public function test()
     {
         $someMock = $this->createMock(\stdClass::class);
         $someMock->expects('method')->willReturn(true);
     }

     public static function someDataProvider(): iterable
     {
         yield [1];
         yield [2];
         yield [3];
     }
 }

Configure your rector.php:

<?php

use Rector\Config\RectorConfig;
use Rector\PHPUnit\PHPUnit120\Rector\Class_\AllowMockObjectsForDataProviderRector;

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