Move property default from constructor to property default
final class SomeClass
{
- private $name;
+ private $name = 'John';
public function __construct()
{
- $this->name = 'John';
}
}
Configure your rector.php
:
<?php
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withRules([
InlineConstructorDefaultToPropertyRector::class,
]);