Add explicit instance assert between above nullable object pass
use PHPUnit\Framework\TestCase;
final class SomeTest extends TestCase
{
public function test()
{
- $someObject = $this->createMock(SomeClass::class);
- $this->process($someObject);
+ $this->process($this->createMock(SomeClass::class));
}
-
private function process(SomeClass $someObject): void
{
}
}
Configure your rector.php:
<?php
use Rector\Config\RectorConfig;
use Rector\PHPUnit\CodeQuality\Rector\ClassMethod\BareCreateMockAssignToDirectUseRector;
return RectorConfig::configure()
->withRules([
BareCreateMockAssignToDirectUseRector::class,
]);