- Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
Description
I have tested this with the current master branch (last commit: ab7e490)
I have 2 examples showing what the sniffer/fixer is doing wrong. The first example is actually fine according to PSR-2, as far as I know.
test_0.php:
<?php if (true) { $test = ' ' . function_0( $argument_0 ); }
$ phpcs --standard=PSR2 test_0.php FILE: C:\[...]\test_0.php ---------------------------------------------------------------------- FOUND 2 ERRORS AFFECTING 2 LINES ---------------------------------------------------------------------- 5 | ERROR | [x] Multi-line function call not indented correctly; | | expected 7 spaces but found 8 6 | ERROR | [x] Multi-line function call not indented correctly; | | expected 3 spaces but found 4 ---------------------------------------------------------------------- PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY ----------------------------------------------------------------------
Result after "fixing":
<?php if (true) { $test = ' ' . function_0( $argument_0 ); }
As you can see, it indents according to the closing single quote instead of the indentation from the variable $test, anything after that is correctly formatted, though.
The second example goes a bit farther than the first one and leads to an endless fixing loop, not fixing anything in that file, in the end.
test_1.php
<?php if (true) { if (true) { $test = ' ' . function_0( $argument_0 ); } }
$ phpcs --standard=PSR2 test_1.php FILE: C:\[...]\test_1.php ---------------------------------------------------------------------- FOUND 2 ERRORS AFFECTING 2 LINES ---------------------------------------------------------------------- 6 | ERROR | [x] Multi-line function call not indented correctly; | | expected 7 spaces but found 12 7 | ERROR | [x] Multi-line function call not indented correctly; | | expected 3 spaces but found 8 ---------------------------------------------------------------------- PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY ----------------------------------------------------------------------
$ phpcbf --no-patch --standard=PSR2 test_1.php Changing into directory C:\[...] Processing test_1.php [PHP => 43 tokens in 9 lines]... DONE in 5ms (2 fixable violations) => Fixing file: 1/2 violations remaining [made 50 passes]... ERROR in 123ms Fixed 0 files