* 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\Casing; use PhpCsFixer\Tests\Test\AbstractFixerTestCase; /** * @author Dariusz Rumiński * * @internal * * @covers \PhpCsFixer\Fixer\Casing\ConstantCaseFixer * * @extends AbstractFixerTestCase<\PhpCsFixer\Fixer\Casing\ConstantCaseFixer> * * @phpstan-import-type _AutogeneratedInputConfiguration from \PhpCsFixer\Fixer\Casing\ConstantCaseFixer */ final class ConstantCaseFixerTest extends AbstractFixerTestCase { /** * @param _AutogeneratedInputConfiguration $configuration * * @dataProvider provideFixCases */ public function testFix(string $expected, ?string $input = null, array $configuration = []): void { $this->fixer->configure($configuration); $this->doTest($expected, $input); } /** * @return iterable */ public static function provideFixCases(): iterable { yield [ '']; yield ['False = 1; $this->True = 2; $this->Null = 3; } }']; foreach (['true', 'false', 'null'] as $case) { yield [ \sprintf(' 'lower'], ]; yield [ \sprintf(' 'lower'], ]; yield [ \sprintf(' 'lower'], ]; yield [ \sprintf(' 'lower'], ]; yield [ \sprintf(' 'lower'], ]; yield [ \sprintf(' 'lower'], ]; } foreach (['true', 'false', 'null'] as $case) { yield [ \sprintf(' 'upper'], ]; yield [ \sprintf(' 'upper'], ]; yield [ \sprintf(' 'upper'], ]; yield [ \sprintf(' 'upper'], ]; yield [ \sprintf(' 'upper'], ]; yield [ \sprintf(' 'upper'], ]; } } /** * @dataProvider provideFix80Cases * * @requires PHP 8.0 */ public function testFix80(string $expected, ?string $input = null): void { $this->doTest($expected, $input); } /** * @return iterable */ public static function provideFix80Cases(): iterable { yield ' nullsafe operator' => ['False; } }']; } /** * @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 'final class const' => [ ' [ ' [ 'doTest($expected, $input); } /** * @return iterable */ public static function provideFix83Cases(): iterable { yield 'typed constant' => [ <<<'PHP'