Closed
Description
Describe the bug
Running PSR2.ControlStructures.SwitchDeclaration.BodyOnNextLineCASE
can remove comments which are on the same line as the case
statement
Code sample
$test = 2;
switch ( $test ) {
case 2: // comment followed by empty line
echo "test 2";
}
Custom ruleset
<?xml version="1.0"?>
<ruleset name="My Custom Standard">
<rule ref="PSR2.ControlStructures.SwitchDeclaration" />
</ruleset>
To reproduce
Steps to reproduce the behavior:
- Create a file called
test.php
with the code sample above... - Run
phpcbf test.php ...
- The comment is gone.
$test = 2;
switch ( $test ) {
case 2:
echo "test 2";
}
Expected behavior
The remove of the empty line is correct, but the comment should stay from my point of view.
Versions (please complete the following information):
- OS: Windows 10
- PHP: 8.0
- PHPCS: 3.6.0
- Standard: -
Additional context
The fixer starts directly after the colon/scope opener to remove everything there, not at the end of the line
Seems an issue since the fix for #683, which ignores the comments, but does not adjust the fixer part.