Describe the bug
For multiple cases grouped together with the same contents, if you put comments in the middle of the different cases, the indentation gets flagged by Generic.WhiteSpace.ScopeIndent.Incorrect
Code sample
<?php
$tmp = 1;
switch ($tmp)
{
case 1:
// This should not get flagged
case 2:
echo 'Test';
break;
}
Custom ruleset
<?xml version="1.0"?>
<ruleset name="My Custom Standard">
<!-- Whitespace -->
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent" />
<rule ref="Generic.WhiteSpace.ScopeIndent">
<properties>
<property name="indent" value="4"/>
<property name="tabIndent" value="true"/>
</properties>
</rule>
</ruleset>
To reproduce
Steps to reproduce the behavior:
- Create a file called
test.php with the code sample above...
- Run
phpcs test.php ...
- See error message displayed
Line indented incorrectly; expected at least 2 tabs, found 1
(Generic.WhiteSpace.ScopeIndent.Incorrect)
Expected behavior
No error should be shown when there are empty contents for the case and a comment there.
Versions (please complete the following information)
|
|
| Operating System |
macOS Tahoe 26.5.1 |
| PHP version |
8.5 |
| PHP_CodeSniffer version |
4.0.1 |
| Standard |
custom |
| Install type |
Composer local |
Additional context
N/A
Please confirm
Describe the bug
For multiple
cases grouped together with the same contents, if you put comments in the middle of the differentcases, the indentation gets flagged byGeneric.WhiteSpace.ScopeIndent.IncorrectCode sample
Custom ruleset
To reproduce
Steps to reproduce the behavior:
test.phpwith the code sample above...phpcs test.php ...Expected behavior
No error should be shown when there are empty contents for the
caseand a comment there.Versions (please complete the following information)
Additional context
N/A
Please confirm
4.xbranch of PHP_CodeSniffer.