i-doit / api-client-php

Easy-to-use, but feature-rich client library for i-doit's JSON-RPC API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

rakoitde opened this issue · comments

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