php-formatter
php-formatter copied to clipboard
Sorting replaces \n by \r\n
When sorting use clauses in PHP files under a Windows system (I used Windows 7, with PHP 7 RC5), the sorting makes the file invalidate a PSR-2 rule, as the line endings appended are the default from Windows (\r\n), instead of the ones from UNIX (\n).
Please see the attached image to apreciate that the endings have only been replaced in use clauses.
Hi there!
Thanks for that feedback :)
This project uses PHP_EOL
for new lines.
https://github.com/mmoreram/php-formatter/blob/master/src/PHPFormatter/Sorter/UseSorter.php#L249
Maybe here is the problem... :/
What do you think?
Hi Marc,
As PSR is the standard, I will suggest to use what the rules say: "All PHP files MUST use the Unix LF (linefeed) line ending."
However, maybe it is interesting for some users to especify their custom new line string, or let them choose which they use from a defined list. For this, I would suggest adding another parameter to the application, and document it consequently, so users can have this flexibility :) If not specified, I would leave by default the Unix line ending (\n) as the PSR rules say.
Would this be something that could fit into the application?
@jdomenechb okay! Will do it :)