Description
Greetings,
I was trying to use phpcbf to fix issues detected by codesniffer in ADOdb library (following PSR-2 standard). The tool seems to go into a loop, and errors out after 50 iterations without fixing anything:
Processing perf-postgres.inc.php [PHP => 902 tokens in 154 lines]... DONE in 71ms (138 fixable violations)
=> Fixing file: 1/138 violations remaining [made 50 passes]... ERROR in 3.6 secs
After some trial and error (applying each sniff individually), I finally managed to isolate the problem to the following code (from https://github.com/ADOdb/ADOdb/blob/master/perf/perf-postgres.inc.php#L112):
<?php
switch ($mode) {
// case statements removed
default :
{
ADOConnection::outp(sprintf("<p>%s: '%s' using of undefined mode '%s'</p>", __CLASS__, 'optimizeTable', $mode));
return false;
}
}
It is now easy to see that the problem is caused by use of curly braces in the default case, as shown in phpcbf output, and I assume that the fixer can't do it's work due to a conflict caused by the error at line 11.
--------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------------------
11 | ERROR | [ ] DEFAULT statements must be defined using a colon
15 | ERROR | [x] Terminating statement must be indented to the same level as the CASE body
--------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------
The problem is that phpcbf does not give a clear indication about what is actually causing the error, and when running it against the original file, the 2 lines above are drown in the midst of 180 errors and warnings, making it difficult and time-consuming to identify the root cause.
Hopefully you can find a way to improve this in a future version.
Many thanks for this excellent software !