Skip to content

Commit 6312ff0

Browse files
committed
Feat: Add SingleLineCommentSpacingFixer (part of #94)
1 parent 00687a4 commit 6312ff0

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

ecs.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
use PhpCsFixer\Fixer\ClassNotation\SingleTraitInsertPerStatementFixer;
6060
use PhpCsFixer\Fixer\ClassNotation\VisibilityRequiredFixer;
6161
use PhpCsFixer\Fixer\Comment\NoEmptyCommentFixer;
62+
use PhpCsFixer\Fixer\Comment\SingleLineCommentSpacingFixer;
6263
use PhpCsFixer\Fixer\ControlStructure\NoUselessElseFixer;
6364
use PhpCsFixer\Fixer\ControlStructure\SwitchContinueToBreakFixer;
6465
use PhpCsFixer\Fixer\ControlStructure\TrailingCommaInMultilineFixer;
@@ -256,6 +257,8 @@
256257
SingleTraitInsertPerStatementFixer::class,
257258
// There should not be any empty comments
258259
NoEmptyCommentFixer::class,
260+
// Single-line comments must have proper spacing.
261+
SingleLineCommentSpacingFixer::class,
259262
// There should not be useless `else` cases
260263
NoUselessElseFixer::class,
261264
// Switch case must not be ended with `continue` but with `break`.

tests/Integration/Fixtures/Basic.correct.php.inc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ class Basic
4444
$baz = implode(',', ['foo', 'bar']);
4545
}
4646

47+
// SingleLineCommentSpacingFixer
48+
// This comment should have space on the beginning
49+
/* So should this one, also with space on the end */
50+
4751
// TernaryToElvisOperatorFixer
4852
return ($foo ?: 'not true');
4953
}

tests/Integration/Fixtures/Basic.wrong.php.inc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ class Basic
4040
$baz = join(',', ['foo', 'bar']);
4141
}
4242

43+
// SingleLineCommentSpacingFixer
44+
//This comment should have space on the beginning
45+
/*So should this one, also with space on the end*/
46+
4347
// TernaryToElvisOperatorFixer
4448
return ($foo ? $foo : 'not true');
4549
}

0 commit comments

Comments
 (0)