Skip to content

Commit

Permalink
Feat: Add LongToShorthandOperatorFixer (part of #94)
Browse files Browse the repository at this point in the history
  • Loading branch information
OndraM committed May 23, 2024
1 parent 878bb87 commit 1b246d7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
use PhpCsFixer\Fixer\NamespaceNotation\NoLeadingNamespaceWhitespaceFixer;
use PhpCsFixer\Fixer\Operator\BinaryOperatorSpacesFixer;
use PhpCsFixer\Fixer\Operator\ConcatSpaceFixer;
use PhpCsFixer\Fixer\Operator\LongToShorthandOperatorFixer;
use PhpCsFixer\Fixer\Operator\NewWithParenthesesFixer;
use PhpCsFixer\Fixer\Operator\NoSpaceAroundDoubleColonFixer;
use PhpCsFixer\Fixer\Operator\ObjectOperatorWithoutWhitespaceFixer;
Expand Down Expand Up @@ -311,6 +312,8 @@
NoLeadingNamespaceWhitespaceFixer::class,
// Binary operators should be surrounded by exactly one single space.
BinaryOperatorSpacesFixer::class,
// Shorthand notation for operators should be used if possible.
LongToShorthandOperatorFixer::class,
// There must be no space around scope resolution double colons
NoSpaceAroundDoubleColonFixer::class,
// All instances created with new keyword must be followed by parentheses.
Expand Down
6 changes: 6 additions & 0 deletions tests/Integration/Fixtures/Basic.correct.php.inc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ class Basic extends AbstractBasic implements InterfaceFromThisNamespace // Fully
$baz = implode(',', ['foo', 'bar']);
}

$i = 3;
$i += 6; // LongToShorthandOperatorFixer
$i *= 2; // LongToShorthandOperatorFixer
$text = 'foo';
$text .= 'bar'; // LongToShorthandOperatorFixer

// HeredocIndentationFixer
$heredoc = <<<HEREDOC
This is a
Expand Down
6 changes: 6 additions & 0 deletions tests/Integration/Fixtures/Basic.wrong.php.inc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ class Basic extends \Some\Other\Namespace\AbstractBasic implements \Lmc\CodingSt
$baz = join(',', ['foo', 'bar']);
}

$i = 3;
$i = $i + 6; // LongToShorthandOperatorFixer
$i = $i * 2; // LongToShorthandOperatorFixer
$text = 'foo';
$text = $text . 'bar'; // LongToShorthandOperatorFixer

// HeredocIndentationFixer
$heredoc = <<<HEREDOC
This is a
Expand Down

0 comments on commit 1b246d7

Please sign in to comment.