* 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\Fixer\Operator\IncrementStyleFixer; use PhpCsFixer\Tests\Test\AbstractFixerTestCase; /** * @author Gregor Harlan * @author Kuba Werłos * * @internal * * @covers \PhpCsFixer\Fixer\AbstractIncrementOperatorFixer * @covers \PhpCsFixer\Fixer\Operator\IncrementStyleFixer * * @extends AbstractFixerTestCase<\PhpCsFixer\Fixer\Operator\IncrementStyleFixer> * * @phpstan-import-type _AutogeneratedInputConfiguration from \PhpCsFixer\Fixer\Operator\IncrementStyleFixer */ final class IncrementStyleFixerTest extends AbstractFixerTestCase { /** * @dataProvider provideFixPreIncrementCases */ public function testFixPreIncrement(string $expected, ?string $input = null): void { $this->fixer->configure(['style' => IncrementStyleFixer::STYLE_PRE]); $this->doTest($expected, $input); } /** * @dataProvider provideFixPostIncrementCases */ public function testFixPostIncrement(string $expected, ?string $input = null): void { $this->fixer->configure(['style' => IncrementStyleFixer::STYLE_POST]); $this->doTest($expected, $input); } /** * @return iterable */ public static function provideFixPostIncrementCases(): iterable { foreach (self::provideFixPreIncrementCases() as $case) { yield array_reverse($case); } } /** * @return iterable */ public static function provideFixPreIncrementCases(): iterable { yield [ 'foo;', 'foo++;', ]; yield [ '{"foo"};', '{"foo"}++;', ]; yield [ '$b;', '$b++;', ]; yield [ 'doTest($expected, $input); } /** * @return iterable */ public static function provideFixPre80Cases(): iterable { yield [ '$b::$c->${$d}->${$e}::f(1 + 2 * 3)->$g::$h;', '$b::$c->${$d}->${$e}::f(1 + 2 * 3)->$g::$h++;', ]; yield [ '{$b."foo"}->bar[$c]->$baz;', '{$b."foo"}->bar[$c]->$baz++;', ]; } }