* 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\LanguageConstruct; use PhpCsFixer\Tests\Test\AbstractFixerTestCase; /** * @author John Paul E. Balandan, CPA * * @internal * * @covers \PhpCsFixer\Fixer\LanguageConstruct\NullableTypeDeclarationFixer * * @extends AbstractFixerTestCase<\PhpCsFixer\Fixer\LanguageConstruct\NullableTypeDeclarationFixer> * * @phpstan-import-type _AutogeneratedInputConfiguration from \PhpCsFixer\Fixer\LanguageConstruct\NullableTypeDeclarationFixer */ final class NullableTypeDeclarationFixerTest extends AbstractFixerTestCase { /** * @dataProvider provideFixCases * * @requires PHP 8.0 */ public function testFix(string $expected, ?string $input = null): void { $this->doTest($expected, $input); } /** * @return iterable */ public static function provideFixCases(): iterable { yield 'scalar with null' => [ " [ " [ ' [ " [ ' [ " true;\n", ]; yield 'skips already fixed' => [ "fixer->configure(['syntax' => 'union']); $this->doTest($expected, $input); } /** * @return iterable */ public static function provideFix80Cases(): iterable { yield 'scalar with null' => [ " [ " [ ' [ " [ ' [ ' [ " [ <<<'PHP' fixer->configure($config); $this->doTest($expected, $input); } /** * @return iterable}> */ public static function provideFix81Cases(): iterable { yield 'readonly property' => [ ' [ ' 'union'], ]; } /** * @param _AutogeneratedInputConfiguration $config * * @dataProvider provideFix82Cases * * @requires PHP 8.2 */ public function testFix82(string $expected, ?string $input = null, array $config = []): void { $this->fixer->configure($config); $this->doTest($expected, $input); } /** * @return iterable}> */ public static function provideFix82Cases(): iterable { yield 'skips DNF types' => [ ' [ ' 'union'], ]; } }