Result of ClassPropertyAssignToConstructorPromotionRector to multiple lines?
#7361
|
Hi, I'm sorry if I missed something but I'm not able to refactor normal properties to promoted ones. It squashes all promoted props into one line. What do I do wrong? There is no configuration or reference to resolve this in the rule docs. Thank you. rector.php use Rector\Config\RectorConfig;
use Rector\Core\Configuration\Option;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/src'
]);
$rectorConfig->importNames(true); // use "use" statements instead of FQN
$rectorConfig->importShortClasses(false); // don't import root classes (e.g. \LogicException)
$rectorConfig->parameters()->set(Option::APPLY_AUTO_IMPORT_NAMES_ON_CHANGED_FILES_ONLY, true); // don't import everything, only affected
$rectorConfig->rule(\Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector::class);
};Code to refactor final class Whatever
{
private int $a;
private string $b;
public function __construct(
int $a,
string $b
) {
$this->a = $a;
$this->b = $b;
}
}Expected final class Whatever
{
public function __construct(
private int $a,
private string $b
) {}
}Actual final class Whatever
{
public function __construct(private int $a, private string $b) {}
}Screenshot from PhpStorm: |
Answered by
samsonasik
Aug 12, 2022
Replies: 1 comment 1 reply
|
That is expected, ref https://github.com/rectorphp/rector#how-to-apply-coding-standards , you may need coding standard tool for that |
1 reply
Answer selected by
dakur
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

That is expected, ref https://github.com/rectorphp/rector#how-to-apply-coding-standards , you may need coding standard tool for that