Skip to content
This repository was archived by the owner on Feb 21, 2022. It is now read-only.

Sorting replaces \n by \r\n #19

Open
jdomenechb opened this issue Oct 20, 2015 · 3 comments
Open

Sorting replaces \n by \r\n #19

jdomenechb opened this issue Oct 20, 2015 · 3 comments

Comments

@jdomenechb
Copy link

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.

sorting_r_n

@mmoreram
Copy link
Owner

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?

@jdomenechb
Copy link
Author

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?

@mmoreram
Copy link
Owner

@jdomenechb okay! Will do it :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants