You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ phpcs --standard=PSR2 --encoding=utf-8 --colors --report=full code4.php
FILE: /home/fmusy/www/projects/app-tests/t/code4.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
6 | ERROR | [x] Whitespace found at end of line
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
Time: 26ms; Memory: 4Mb
The text was updated successfully, but these errors were encountered:
gsherwood
changed the title
Invalid handling of array destructuring
Scope indent calculated incorrectly when using array destructuring
Mar 19, 2017
The issue was caused by the T_WHITESPACE token setting the indent, when it never should. This was due to an assumption in the sniff that a square bracket would never be the first piece of code in a statement.
Debug output was:
Start with token 0 on line 1 with indent 0
Closing parenthesis found on line 2
* ignoring single-line definition *
Open scope (T_FUNCTION) on line 3
=> indent set to 4 by token 7 (T_OPEN_CURLY_BRACKET)
Closing short array bracket found on line 4
* ignoring single-line definition *
Closing parenthesis found on line 5
* ignoring single-line definition *
Open scope (T_FOREACH) on line 5
=> indent set to 8 by token 29 (T_OPEN_CURLY_BRACKET)
Closing short array bracket found on line 9
* first token on line 6 is 32 (T_OPEN_SHORT_ARRAY) *
=> checking indent of 8; main indent set to 0 by token 31 (T_WHITESPACE)
[Line 10] Line indented incorrectly; expected 0 spaces, found 8
=> Add adjustment of -8 for token 59 (T_FOREACH) on line 10
Closing parenthesis found on line 10
* ignoring single-line definition *
Open scope (T_FOREACH) on line 10
=> indent set to 4 by token 69 (T_OPEN_CURLY_BRACKET)
Indent adjusted to 4 for T_ECHO on line 11
=> Add adjustment of -8 for token 72 (T_ECHO) on line 11
Close scope (T_FOREACH) on line 12
=> indent set to 0 by token 82 (T_CLOSE_CURLY_BRACKET)
[Line 12] Line indented incorrectly; expected 0 spaces, found 8
=> Add adjustment of -8 for token 82 (T_CLOSE_CURLY_BRACKET) on line 12
Close scope (T_FOREACH) on line 13
=> indent set to 4 by token 85 (T_CLOSE_CURLY_BRACKET)
Close scope (T_FUNCTION) on line 14
=> indent set to 0 by token 87 (T_CLOSE_CURLY_BRACKET)
When destructuring an array (PHP 7.1) , false positives are triggered.
Running phpcs 2.8.1 against the file will report an unexpected indent violation:
If destructuration is done in one line, no violation is reported.
If destructuration is done with
array
keyword, phpcs reports an invalid withespace at EOL:with output
The text was updated successfully, but these errors were encountered: