- Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
Description
Running PHPCS 2.6.1 on PHP 5.6.21
It seems that when declaring multiple class properties / members of the same visibility as arrays using commas this causes ScopeIndent to increase the default indentation of the rest of the file by one level.
Sample file:
<?php class Test123 { protected static $prop1 = [ 'testA' => 123, ], $prop2 = [ 'testB' => 456, ]; protected $prop3; }
Error/Diff:
phpcs --standard=Squiz --sniffs=Generic.WhiteSpace.ScopeIndent test.php --report=diff
--- test.php +++ PHP_CodeSniffer @@ -10,6 +10,6 @@ 'testB' => 456, ]; - protected + protected $prop3; }
Debug output:
*** START TOKEN PROCESSING *** Process token 0: T_OPEN_TAG => <?php\n Processing Generic_Sniffs_WhiteSpace_ScopeIndentSniff... Start with token 0 on line 1 with indent 0 Open scope (T_CLASS) on line 4 => indent set to 4 by token 6 (T_OPEN_CURLY_BRACKET) Closing short array bracket found on line 8 * first token on line 6 is 14 (T_VARIABLE) * * previous is T_PROTECTED on line 5 * * amended first token is 9 (T_PROTECTED) on line 5 * => checking indent of 8; main indent set to 4 by token 9 (T_PROTECTED) Closing short array bracket found on line 11 * first token on line 9 is 33 (T_VARIABLE) * => checking indent of 8; main indent set to 8 by token 33 (T_VARIABLE) [Line 13] Line indented incorrectly; expected 8 spaces, found 4 Generic_Sniffs_WhiteSpace_ScopeIndentSniff (line 788) replaced token 52 (T_WHITESPACE) "····protected" => "········protected" => Add adjustment of 4 for token 53 (T_PROTECTED) on line 13 Close scope (T_CLASS) on line 15 => indent set to 0 by token 59 (T_CLOSE_CURLY_BRACKET) DONE in 0.0006 seconds