diff --git a/ecs.php b/ecs.php index 1346cb1..08ea7af 100644 --- a/ecs.php +++ b/ecs.php @@ -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; @@ -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. diff --git a/tests/Integration/Fixtures/Basic.correct.php.inc b/tests/Integration/Fixtures/Basic.correct.php.inc index ad05bd6..19ad0be 100644 --- a/tests/Integration/Fixtures/Basic.correct.php.inc +++ b/tests/Integration/Fixtures/Basic.correct.php.inc @@ -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 = <<