Change setUpBeforeClass() to setUp() if not needed
use PHPUnit\Framework\TestCase;
final class SomeTest extends TestCase
{
- private static $someService;
+ private $someService;
- public static function setUpBeforeClass(): void
+ protected function setUp(): void
{
- self::$someService = new SomeService();
+ $this->someService = new SomeService();
}
public function test()
{
- $result = self::$someService->getValue();
+ $result = $this->someService->getValue();
}
}
Configure your rector.php
:
<?php
use Rector\Config\RectorConfig;
use Rector\PHPUnit\CodeQuality\Rector\Class_\SetUpBeforeClassToSetUpRector;
return RectorConfig::configure()
->withRules([
SetUpBeforeClassToSetUpRector::class,
]);