* Dariusz RumiƄski * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer\Tests\Fixer\Operator; use PhpCsFixer\Tests\Test\AbstractFixerTestCase; /** * @author ntzm * * @internal * * @covers \PhpCsFixer\Fixer\AbstractIncrementOperatorFixer * @covers \PhpCsFixer\Fixer\Operator\StandardizeIncrementFixer * * @extends AbstractFixerTestCase<\PhpCsFixer\Fixer\Operator\StandardizeIncrementFixer> */ final class StandardizeIncrementFixerTest extends AbstractFixerTestCase { /** * @dataProvider provideFixCases */ public function testFix(string $expected, ?string $input = null): void { $this->doTest($expected, $input); } /** * @return iterable */ public static function provideFixCases(): iterable { yield [ 'bar;', 'bar += 1;', ]; yield [ '$bar;', '$bar += 1;', ]; yield [ '$$$bar;', '$$$bar += 1;', ]; yield [ 'baz];', 'baz] += 1;', ]; yield [ '{++$a};', '{$a += 1} += 1;', ]; yield [ '', '', ]; yield [ '{++$b}[++$c];', '{$b += 1}[$c += 1] += 1;', ]; yield [ 'b->$c;', 'b->$c += 1;', ]; yield [ 'bar;', 'bar -= 1;', ]; yield [ '$bar;', '$bar -= 1;', ]; yield [ '$$$bar;', '$$$bar -= 1;', ]; yield [ 'baz];', 'baz] -= 1;', ]; yield [ '{$bar};', '{$bar} -= 1;', ]; yield [ '{$bar->{$baz}};', '{$bar->{$baz}} -= 1;', ]; yield [ '{--$a};', '{$a -= 1} -= 1;', ]; yield [ '', '', ]; yield [ '{--$b}[--$c];', '{$b -= 1}[$c -= 1] -= 1;', ]; yield [ 'b->$c;', 'b->$c -= 1;', ]; yield [ '> 2;', ]; yield [ ' 2;', ]; yield [ '= 2;', ]; yield [ ' 2;', ]; yield [ '> 2;', ]; yield [ ' 2;', ]; yield [ '= 2;', ]; yield [ ' 2;', ]; yield [ '$c;', '$c += 1;', ]; yield [ ' 2;', ]; yield [ ' 2;', ]; yield [ '$b::$c;', '$b::$c += 1;', ]; yield [ '$b::$c->${$d}->${$e}::f(1 + 2 * 3)->$g::$h;', '$b::$c->${$d}->${$e}::f(1 + 2 * 3)->$g::$h += 1;', ]; yield [ 'doTest($expected, $input); } /** * @return iterable */ public static function provideFixPre80Cases(): iterable { yield [ '{$bar};', '{$bar} += 1;', ]; yield [ '{$bar->{$baz}};', '{$bar->{$baz}} += 1;', ]; yield [ '