Change param type of a private test method to MockObject, when expects() is called on it
+use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
final class SomeTest extends TestCase
{
- private function prepareUserMock(SomeUser $user): void
+ private function prepareUserMock(MockObject $user): void
{
$user->expects($this->once())
->method('getId');
}
}
Configure your rector.php:
<?php
use Rector\Config\RectorConfig;
use Rector\PHPUnit\PHPUnit110\Rector\ClassMethod\ExpectsParamToMockObjectRector;
return RectorConfig::configure()
->withRules([
ExpectsParamToMockObjectRector::class,
]);