Change __construct() method in tests of PHPUnit\Framework\TestCase
to setUp(), to prevent dangerous override
use PHPUnit\Framework\TestCase;
final class SomeTest extends TestCase
{
private $someValue;
- public function __construct(?string $name = null, array $data = [], string $dataName = '')
+ protected function setUp()
{
+ parent::setUp();
+
$this->someValue = 1000;
- parent::__construct($name, $data, $dataName);
}
}
Configure your rector.php
:
<?php
use Rector\Config\RectorConfig;
use Rector\PHPUnit\CodeQuality\Rector\Class_\ConstructClassMethodToSetUpTestCaseRector;
return RectorConfig::configure()
->withRules([
ConstructClassMethodToSetUpTestCaseRector::class,
]);