PedroTroller / PhpCSFixer-Custom-Fixers

A set of new fixers for PHP-CS-Fixer
77 stars 7 forks source link

line_break_between_method_arguments should count from beginning of line, including whitespaces #207

Open ostrolucky opened 7 months ago

ostrolucky commented 7 months ago

I thought this fixer is great fit in combination with PSR-2's recommended 120 line length limit.

However, it looks like line_break_between_method_arguments is trimming the line from whitespaces and only then starts to calculate if content is longer than max-length.

This makes behavior quite non-compatible and non-predictable, because max-length is depending on indentation of current line. If I set it to 120 lines with intention to stick with PSR-2 limit, this will not work for intended code like so

     public function __construct(
         #[Assert\NotBlank(message: 'not_blank')]
         private string|UuidInterface $userFileImportId,
-        #[Assert\Choice(
-            callback: ['Eqsgroup\Entity\UserImport', 'getDuplicateResolutionStrategies'],
-            message: 'invalid_strategy',
-        )]
+        #[Assert\Choice(callback: ['Eqsgroup\Entity\UserImport', 'getDuplicateResolutionStrategies'], message: 'invalid_strategy', )]
         private string $strategy,
     ) {}

^ fixer changes above because even though code after fixing is longer than 120 lines, without whitespaces it's not

Attributes can be nested infinite times, which will push the limit towards PSR's 120 line length limit, but max-length option does not care about that