Now that https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/4746 is merged, code that previously looked like:
final class SomeSubscriber
{
/**
* @var RefundRepository
*/
private RefundRepository $refundRepository;
/**
* @var CommandBus
*/
private CommandBus $commandBus;
/**
* @var EventBus
*/
private EventBus $eventBus;
public function __construct()
{
// Do something
}
}
will be changed to:
final class SomeSubscriber
{
private RefundRepository $refundRepository;
private CommandBus $commandBus;
private EventBus $eventBus;
public function __construct()
{
// Do something
}
}
But I really want it to be changed to:
final class SomeSubscriber
{
private RefundRepository $refundRepository;
private CommandBus $commandBus;
private EventBus $eventBus;
public function __construct()
{
// Do something
}
}
@SpacePossum Is this already supported? If not, could or should this be added to an existing fixer like NoExtraBlankLinesFixer?
If I get some input on what the best place is, I will create the PR for it 馃槉
I think this could be implemented as a new option for rule class_attributes_separation (e.g. choosing between 0 or 1 line instead of always 1).
I agree with Julien here; class_attributes_separation sounds like a good spot as another would be in conflict with class_attributes_separation.
class_attributes_separation already has configuration options, like ['elements' => ['property', 'const']] etc., maybe it would be better to add the option on these?
Something like ['elements' => ['property' => 'none', 'const' => 'none', 'method' => 'single_line']]
I think this should target master as new feature, WDYT Julien?
Sounds good :)
Thanks for the fast feedback :) I'm gonna work on a PR.
I'm looking at https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/4593/files#diff-e3af88851780597943694e86c3d71048R679-R689 and I wonder where and why was decided that typed properties should always be separated by newlines? Is that a PSR rule?
Because I find it interesting that PSR-12 shows an example without newlines between the properties: https://www.php-fig.org/psr/psr-12/#43-properties-and-constants
I think it was derived from a PSR2 sample, even though there is none with multiple properties. Also; up to now it was a wide used standard to separate the properties with a line. Seeing that PSR12 now provides a different standard style all the better to give people option to use that :)
Closing as #4875 was merged.
Most helpful comment
Thanks for the fast feedback :) I'm gonna work on a PR.