* 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 * * @extends AbstractFixerTestCase<\PhpCsFixer\Fixer\ControlStructure\SwitchCaseSemicolonToColonFixer> */ final class SwitchCaseSemicolonToColonFixerTest 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"]: break; } ', ' "bar"]; break; } ', ]; yield [ ' [ 'doTest($expected, $input); } /** * @return iterable */ public static function provideFixPre80Cases(): iterable { yield [ 'doTest($expected, $input); } /** * @return iterable */ public static function provideFix80Cases(): iterable { yield 'Simple match' => [ ' "foo", }; ', ]; yield 'Match in switch' => [ ' "foo", }; break; } ', ]; yield '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); } /** * @return iterable */ public static function provideFix81Cases(): iterable { yield 'enums' => [ ' baz(), }; } }; $a->bar(); break; } return "label"; } } $expressionResult = match ($condition) { default => baz(), }; ', ' baz(), }; } }; $a->bar(); break; } return "label"; } } $expressionResult = match ($condition) { default => baz(), }; ', ]; } }