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

phpcs on windows throws on every file following error: End of line character is invalid; expected "\n" but found "\r\n" #32

Open
rakoitde opened this issue Aug 14, 2023 · 0 comments

Comments

@rakoitde
Copy link
Contributor

Actual behavior

phpcs on windows throws on every file following error: End of line character is invalid; expected "\n" but found "\r\n"

FILE: ...\MAMP\htdocs\api-client-php\tests\Idoit\APIClient\SubnetTest.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but
   |       |     found "\r\n"
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Found this Issue:
squizlabs/PHP_CodeSniffer#2554

Steps to resolve the behavior

I'm not firm with phpcs, so I can't judge if my successful test can be a solution!

  1. create ruleset.xlm from following link
    https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/src/Standards/PSR2/ruleset.xml

  2. Change eolChar from "\n" to "\r\n"

    <rule ref="Generic.Files.LineEndings">
        <properties>
            <property name="eolChar" value="\r\n"/>
        </properties>
    </rule>
  1. comment excludes
<!-- checked by PSR2.Classes.ClassDeclaration -->
<!-- <rule ref="Squiz.Functions.MultiLineFunctionDeclaration"/> -->
  1. add script in composer.json

"phpcs-win": "./vendor/bin/phpcs --standard=ruleset.xml --extensions=php src/ tests/",

  1. Test works fine

composer phpcs-win

Environment

Windows

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

No branches or pull requests

1 participant