End of line character is invalid; expected "\r\n" but found "\n"
<?xml version="1.0"?>
<ruleset name="Custom">
<description>Custom Coding Standards</description>
<rule ref="Generic.CodeAnalysis.EmptyStatement" />
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop" />
<rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall" />
<rule ref="Generic.CodeAnalysis.JumbledIncrementer" />
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement" />
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier" />
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter" />
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod" />
<rule ref="Generic.Classes.DuplicateClassName" />
<rule ref="Generic.Commenting.Todo" />
<rule ref="Generic.Files.LineEndings">
<properties>
<property name="eolChar" value="\r\n" />
</properties>
</rule>
<rule ref="Generic.Functions.FunctionCallArgumentSpacing" />
<rule ref="Generic.Formatting.MultipleStatementAlignment" />
<rule ref="Generic.WhiteSpace.DisallowTabIndent" />
<rule ref="Generic.NamingConventions.ConstructorName" />
<rule ref="Generic.NamingConventions.UpperCaseConstantName" />
<rule ref="Generic.PHP.DeprecatedFunctions" />
<rule ref="Generic.PHP.DisallowShortOpenTag" />
<rule ref="Generic.PHP.LowerCaseConstant" />
<rule ref="Generic.PHP.LowerCaseKeyword" />
<rule ref="Generic.PHP.NoSilencedErrors" />
<rule ref="PEAR.Functions.ValidDefaultValue" />
<rule ref="PEAR.NamingConventions.ValidClassName" />
<rule ref="Squiz.Arrays.ArrayBracketSpacing" />
<rule ref="Squiz.Strings.ConcatenationSpacing" />
<rule ref="Squiz.ControlStructures.ControlSignature">
<severity>0</severity>
</rule>
<rule ref="Squiz.ControlStructures.ElseIfDeclaration" />
<rule ref="Squiz.ControlStructures.ForEachLoopDeclaration" />
<rule ref="Squiz.ControlStructures.ForLoopDeclaration" />
<rule ref="Squiz.ControlStructures.InlineIfDeclaration" />
<rule ref="Squiz.ControlStructures.LowercaseDeclaration" />
<rule ref="Squiz.ControlStructures.SwitchDeclaration" />
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
<properties>
<property name="equalsSpacing" value="1" />
</properties>
</rule>
<rule ref="Squiz.Functions.FunctionDeclaration" />
<rule ref="Squiz.Functions.LowercaseFunctionKeywords" />
<rule ref="Squiz.Operators.IncrementDecrementUsage" />
<rule ref="Squiz.PHP.CommentedOutCode" />
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing" />
<rule ref="Squiz.WhiteSpace.OperatorSpacing" />
<rule ref="Squiz.WhiteSpace.ScopeKeywordSpacing" />
<rule ref="Squiz.WhiteSpace.SemicolonSpacing" />
<exclude-pattern>*/.git/*</exclude-pattern>
</ruleset>
If the first line is using \r\n and the rest of the file is using \n, then yes, PHP_CodeSniffer would see the whole fine being on a single line. It uses the first EOL char sequence it finds to determine the EOL char used for tokenising the file. It also uses this EOL to throw an error if it is incorrect.
You are hiding warnings, but if you weren't, you'd see this instead: 1 | WARNING | File has mixed line endings; this may cause incorrect results. That warning has the code Internal.LineEndings.Mixed, which means it is an internal warning that you don't have to add to a ruleset to get. If you find it useful, you can turn it into a proper error:
<rule ref="Internal.LineEndings.Mixed">
<type>error</type>
</rule>
Does this sound like what might be happening with your file?
Forgot to add: thanks for the very detailed report. One of the best I've gotten :)
No problem :smile:
That new rule worked like a charm and was able to clean things up so thanks
Most helpful comment
If the first line is using
\r\nand the rest of the file is using\n, then yes, PHP_CodeSniffer would see the whole fine being on a single line. It uses the first EOL char sequence it finds to determine the EOL char used for tokenising the file. It also uses this EOL to throw an error if it is incorrect.You are hiding warnings, but if you weren't, you'd see this instead:
1 | WARNING | File has mixed line endings; this may cause incorrect results. That warning has the codeInternal.LineEndings.Mixed, which means it is an internal warning that you don't have to add to a ruleset to get. If you find it useful, you can turn it into a proper error:Does this sound like what might be happening with your file?