-
-
Notifications
You must be signed in to change notification settings - Fork 89
Open
Description
Describe the bug
The Generic.WhiteSpace.ScopeIndent sniff incorrectly flags code within a closure, and directly following a nested closure as having the wrong indent, while the indent is correct.
Code sample
Anonymized minimal reproduction sample:
$obj->callA($foo)
->callB(function (string $bar) use ($baz) {
$joined = function (array $newParts) {
return implode('/', $newParts);
};
foreach ($something as $foobar) {
return $foobar;
}
})
;To reproduce
Steps to reproduce the behavior:
- Create a file called
test.phpwith the code sample above... - Run
phpcs test.php --standard=generic--sniffs=generic.whitespace.scopeindent - See error message displayed
------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------------------------
9 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8 (Generic.WhiteSpace.ScopeIndent.IncorrectExact)
11 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8 (Generic.WhiteSpace.ScopeIndent.IncorrectExact)
------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------
☝🏻 Line 9 is the foreach line, line 11, the line with the closing brace for the foreach.
Expected behavior
No errors from this sniff.
Versions (please complete the following information)
| Operating System | not relevant |
| PHP version | not relevant |
| PHP_CodeSniffer version | 4.x |
| Standard | Generic |
| Install type | git clone |
Please confirm
- I have searched the issue list and am not opening a duplicate issue.
- I have read the Contribution Guidelines and this is not a support question.
- I confirm that this bug is a bug in PHP_CodeSniffer and not in one of the external standards.
- I have verified the issue still exists in the
4.xbranch of PHP_CodeSniffer.