* 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\ControlStructure; use PhpCsFixer\Tests\Test\AbstractFixerTestCase; /** * @internal * * @covers \PhpCsFixer\Fixer\ControlStructure\SwitchCaseSemicolonToColonFixer */ final class SwitchCaseSemicolonToColonFixerTest extends AbstractFixerTestCase { /** * @dataProvider provideFixCases */ public function testFix(string $expected, ?string $input = null): void { $this->doTest($expected, $input); } public function provideFixCases(): \Generator { yield from [ [ ' "bar"]: break; } ', ' "bar"]; break; } ', ], [ ' [ 'doTest($expected, $input); } public function provideFixPre80Cases(): \Generator { yield [ 'doTest($expected, $input); } public function provideFix80Cases(): array { return [ 'Simple match' => [ ' "foo", }; ', ], 'Match in switch' => [ ' "foo", }; break; } ', ], 'Match in case value' => [ ' "foo", }: echo "It works!"; } ', ' "foo", }; echo "It works!"; } ', ], ]; } /** * @dataProvider provideFix81Cases * @requires PHP 8.1 */ public function testFix81(string $expected, ?string $input = null): void { $this->doTest($expected, $input); } public function provideFix81Cases(): \Generator { yield 'enums' => [ ' baz(), }; } }; $a->bar(); break; } return "label"; } } $expressionResult = match ($condition) { default => baz(), }; ', ' baz(), }; } }; $a->bar(); break; } return "label"; } } $expressionResult = match ($condition) { default => baz(), }; ', ]; } }