Spaces not replaced with tabs after fix from PEAR.Functions.FunctionCallSignature.Indent while using Generic.WhiteSpace.DisallowSpaceIndent and <arg name="tab-width" value="4"/>
Running PHP_CodeSniffer version 2.6.2 (stable)
Possibly related to similar issues reported in #1056
I have a ruleset.xml subset that I can consistently reproduce this issue with
<?xml version="1.0"?>
<ruleset name="MyStandard">
<description>My custom coding standard.</description>
<arg name="tab-width" value="4"/>
<arg name="encoding" value="utf-8"/>
<!-- Use Unix newlines -->
<rule ref="Generic.Files.LineEndings">
<properties>
<property name="eolChar" value="\n" />
</properties>
</rule>
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent"/>
<rule ref="PEAR.Functions.FunctionCallSignature">
<properties>
<property name="indent" value="4"/>
</properties>
<exclude name="PEAR.Functions.FunctionDeclaration.BraceOnNewLine" />
<exclude name="PEAR.Functions.FunctionCallSignature.CloseBracketLine" />
<exclude name="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket" />
</rule>
</ruleset>
NOTE: the tested file must also have End of line character is invalid; expected "\n" but found "\r\n" error (my eolChar error is on line 1)
I'm testing against Joomla administrator\components\com_categories\models\categories.php and getting 297 | ERROR | [x] Multi-line function call not indented correctly; expected 8 spaces but found 12 (PEAR.Functions.FunctionCallSignature.Indent)
after the fix is applied I get spaces not tabs (the Generic.Files.LineEndings is required to reproduce)
The problem was actually the fixing of the line endings:
*** START FILE FIXING ***
---START FILE CONTENT---
1|<?php
2|function foo()
3|{
4| $query->group('a.id,
5| uc.name,
6| ag.title,
7| ua.name'
8| );
9|}
10|
--- END FILE CONTENT ---
E: [Line 1] End of line character is invalid; expected "\n" but found "\r" (Generic.Files.LineEndings.InvalidEOLChar)
Generic_Sniffs_Files_LineEndingsSniff (line 134) replaced token 0 (T_OPEN_TAG) "<?php\r" => "<?php\n"
Generic_Sniffs_Files_LineEndingsSniff (line 134) replaced token 6 (T_WHITESPACE) "\r{" => "\n{"
Generic_Sniffs_Files_LineEndingsSniff (line 134) replaced token 8 (T_WHITESPACE) "\r\t" => "\n\t"
Generic_Sniffs_Files_LineEndingsSniff (line 134) replaced token 14 (T_CONSTANT_ENCAPSED_STRING) "'a.id,路\r" => "'a.id,路\n"
Generic_Sniffs_Files_LineEndingsSniff (line 134) replaced token 15 (T_CONSTANT_ENCAPSED_STRING) "\t\t\tuc.name,路\r" => "路路路路路路路路路路路路uc.name,路\n"
Generic_Sniffs_Files_LineEndingsSniff (line 134) replaced token 16 (T_CONSTANT_ENCAPSED_STRING) "\t\t\tag.title,路\r" => "路路路路路路路路路路路路ag.title,路\n"
Generic_Sniffs_Files_LineEndingsSniff (line 134) replaced token 18 (T_WHITESPACE) "\r\t\t" => "\n\t\t"
Generic_Sniffs_Files_LineEndingsSniff (line 134) replaced token 22 (T_WHITESPACE) "\r}" => "\n}"
Generic_Sniffs_Files_LineEndingsSniff (line 134) replaced token 24 (T_WHITESPACE) "\r" => "\n"
E: [Line 8] Multi-line function call not indented correctly; expected 4 spaces but found 8 (PEAR.Functions.FunctionCallSignature.Indent)
PEAR_Sniffs_Functions_FunctionCallSignatureSniff (line 464) replaced token 19 (T_WHITESPACE) "\t\t)" => "路路路路)"
* fixed 10 violations, starting loop 2 *
Fixed now. Thanks for reporting it.
Forgot to say thanks for the clear bug report. Made it really easy to replicate and track down.
You are welcome. Thanks for the fix.
Most helpful comment
Fixed now. Thanks for reporting it.