Skip to content

Commit

Permalink
Feat: Add SingleLineCommentSpacingFixer (part of #94)
Browse files Browse the repository at this point in the history
  • Loading branch information
OndraM committed May 6, 2024
1 parent 54ead55 commit 2bf741b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
use PhpCsFixer\Fixer\ClassNotation\SingleTraitInsertPerStatementFixer;
use PhpCsFixer\Fixer\ClassNotation\VisibilityRequiredFixer;
use PhpCsFixer\Fixer\Comment\NoEmptyCommentFixer;
use PhpCsFixer\Fixer\Comment\SingleLineCommentSpacingFixer;
use PhpCsFixer\Fixer\ControlStructure\NoUselessElseFixer;
use PhpCsFixer\Fixer\ControlStructure\SwitchContinueToBreakFixer;
use PhpCsFixer\Fixer\ControlStructure\TrailingCommaInMultilineFixer;
Expand Down Expand Up @@ -255,6 +256,8 @@
SingleTraitInsertPerStatementFixer::class,
// There should not be any empty comments
NoEmptyCommentFixer::class,
// Single-line comments must have proper spacing.
SingleLineCommentSpacingFixer::class,
// There should not be useless `else` cases
NoUselessElseFixer::class,
// Switch case must not be ended with `continue` but with `break`.
Expand Down
4 changes: 4 additions & 0 deletions tests/Integration/Fixtures/Basic.correct.php.inc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ class Basic
$baz = implode(',', ['foo', 'bar']);
}

// SingleLineCommentSpacingFixer
// This comment should have space on the beginning
/* So should this one, also with space on the end */

// TernaryToElvisOperatorFixer
return ($foo ?: 'not true');
}
Expand Down
4 changes: 4 additions & 0 deletions tests/Integration/Fixtures/Basic.wrong.php.inc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ class Basic
$baz = join(',', ['foo', 'bar']);
}

// SingleLineCommentSpacingFixer
//This comment should have space on the beginning
/*So should this one, also with space on the end*/

// TernaryToElvisOperatorFixer
return ($foo ? $foo : 'not true');
}
Expand Down

0 comments on commit 2bf741b

Please sign in to comment.