Turn property used only in setUp() to variable
use PHPUnit\Framework\TestCase;
class SomeServiceTest extends TestCase
{
- private $someServiceMock;
-
public function setUp(): void
{
- $this->someServiceMock = $this->createMock(SomeService::class);
+ $someServiceMock = $this->createMock(SomeService::class);
}
}
Configure your rector.php
:
<?php
use Rector\Config\RectorConfig;
use Rector\PHPUnit\CodeQuality\Rector\Class_\NarrowUnusedSetUpDefinedPropertyRector;
return RectorConfig::configure()
->withRules([
NarrowUnusedSetUpDefinedPropertyRector::class,
]);