Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds windows-latest to github action tests and corrects PHP_EOL to \n… #879

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

marcing
Copy link
Contributor

@marcing marcing commented Feb 2, 2024

  • bumped actions to v4 to avoid warnings

Corrected PHP_EOL to \n, because of was not a proper fix for that.

@mnapoli
Copy link
Member

mnapoli commented Feb 2, 2024

Hi, could you explain a bit more the changes? Using that constant is usually considered a good practice. I'm surprised you want to revert a change that was done 8 years ago.

@SvenRtbg
Copy link
Contributor

SvenRtbg commented Feb 2, 2024

I don't know about the motivation, however the constant is platform dependent, and that can result in all kinds of "unreliable line endings" issues if you work cross-platform in any way. If Windows is used to create a file, and Linux consumes it or vice versa, relying on PHP_EOL pretends to deal with that issue, but instead creates it.

So in essence, I would not call it "best practice" to use it. It may be useful in certain situations where outputting to some platform-dependent channel (like the console) is better done using PHP_EOL - on the other side the Windows port of PHP really goes to great lengths making the Windows behind it invisible, e.g. paths do not need to use backslashes, they can use slashes on Windows.

Still I wonder what issue this would resolve, and I am waiting to read an answer as well.

@mnapoli
Copy link
Member

mnapoli commented Feb 2, 2024

Yeah you make a good point. I'm more in the camp of "what is wrong now, and what is fixed with this PR" because it's a significant change.

@marcing
Copy link
Contributor Author

marcing commented Feb 5, 2024

@mnapoli @SvenRtbg

The issue here was that we replaced \n with PHP_EOL in methods, which are used to compare strings present in unit test source files. Variables with strings containing line endings should not depend on platform (contrary to some file system operations). The coding standard on the project uses \n as EOL, that is why we should not compare it against \r\n (which is the value of PHP_EOL on Windows). The original pull request from 8 years ago passed tests only because of local GIT settings of the author, which converted \n in source code to \r\n when checking out, which was essentially an alteration of the source code files. This pull request fixes that, because the tests did not pass on Windows since then. New github action was added which runs the tests on windows, additionally with git config --global core.eol lf configuration to make sure same line endings are the same as the ones in source files.

Let me know what you think guys, I'm open for discussing it further. Thank you.

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

Successfully merging this pull request may close these issues.

None yet

3 participants