Make properties in tests with intersection mock object either object type or mock type
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\MockObject\MockObject;
final class MockingEntity extends TestCase
{
- private SimpleObject|MockObject $someEntityMock;
+ private MockObject $someEntityMock;
protected function setUp(): void
{
$this->someEntityMock = $this->createMock(SimpleObject::class);
}
}
Configure your rector.php
:
<?php
use Rector\Config\RectorConfig;
use Rector\PHPUnit\CodeQuality\Rector\Class_\SingleMockPropertyTypeRector;
return RectorConfig::configure()
->withRules([
SingleMockPropertyTypeRector::class,
]);