Skip to content

Commit 2bf741b

Browse files
committed
Feat: Add SingleLineCommentSpacingFixer (part of #94)
1 parent 54ead55 commit 2bf741b

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;
@@ -255,6 +256,8 @@
255256
SingleTraitInsertPerStatementFixer::class,
256257
// There should not be any empty comments
257258
NoEmptyCommentFixer::class,
259+
// Single-line comments must have proper spacing.
260+
SingleLineCommentSpacingFixer::class,
258261
// There should not be useless `else` cases
259262
NoUselessElseFixer::class,
260263
// 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
@@ -42,6 +42,10 @@ class Basic
4242
$baz = implode(',', ['foo', 'bar']);
4343
}
4444

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

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

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

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

0 commit comments

Comments
 (0)