* 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 */ final class NullableTypeDeclarationFixerTest extends AbstractFixerTestCase { /** * @dataProvider provideDefaultFixCases * * @requires PHP 8.0 */ public function testDefaultFix(string $expected, ?string $input = null): void { $this->doTest($expected, $input); } /** * @return iterable> */ public static function provideDefaultFixCases(): iterable { yield 'scalar with null' => [ " [ " [ ' [ " [ ' [ " true;\n", ]; yield 'skips already fixed' => [ "fixer->configure(['syntax' => 'union']); $this->doTest($expected, $input); } /** * @return iterable> */ public static function provideFixWithUnionSyntaxCases(): iterable { yield 'scalar with null' => [ " [ " [ ' [ " [ ' [ ' [ " $config * * @dataProvider provideFixPhp81Cases * * @requires PHP 8.1 */ public function testFixPhp81(string $expected, ?string $input = null, ?array $config = null): void { if (null !== $config) { $this->fixer->configure($config); } $this->doTest($expected, $input); } /** * @return iterable|string>> */ public static function provideFixPhp81Cases(): iterable { yield 'readonly property' => [ ' [ ' 'union'], ]; } /** * @param null|array $config * * @dataProvider provideFixPhp82Cases * * @requires PHP 8.2 */ public function testFixPhp82(string $expected, ?string $input = null, ?array $config = null): void { if (null !== $config) { $this->fixer->configure($config); } $this->doTest($expected, $input); } /** * @return iterable|string>> */ public static function provideFixPhp82Cases(): iterable { yield 'skips DNF types' => [ '