/* Decoded by unphp.net */ * 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\FunctionNotation; use PhpCsFixer\Tests\Test\AbstractFixerTestCase; /** * @author Filippo Tessarotto * * @internal * * @group phpdoc * * @covers \PhpCsFixer\Fixer\FunctionNotation\PhpdocToReturnTypeFixer * * @extends AbstractFixerTestCase<\PhpCsFixer\Fixer\FunctionNotation\PhpdocToReturnTypeFixer> * * @phpstan-import-type _AutogeneratedInputConfiguration from \PhpCsFixer\Fixer\FunctionNotation\PhpdocToReturnTypeFixer */ final class PhpdocToReturnTypeFixerTest extends AbstractFixerTestCase { /** * @param _AutogeneratedInputConfiguration $config * * @dataProvider provideFixCases */ public function testFix(string $expected, ?string $input = null, array $config = []): void { $this->fixer->configure($config); $this->doTest($expected, $input); } public static function provideFixCases(): iterable { yield 'no phpdoc return' => [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' false], ]; yield 'do not fix union types when configured as such' => [ ' false], ]; yield 'array native type' => [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' */ function my_foo(): array {}', ' */ function my_foo() {}', ]; yield 'array of types' => [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' 1;', ' 1;', ]; yield 'arrow function (static)' => [ ' 1;', ' 1;', ]; yield 'arrow function (as argument ended with ,)' => [ ' [$a], fn($a, $b) => 1, );', ' [$a], fn($a, $b) => 1, );', ]; } /** * @dataProvider provideFixPre80Cases * * @requires PHP <8.0 */ public function testFixPre80(string $expected, ?string $input = null): void { $this->doTest($expected, $input); } public static function provideFixPre80Cases(): iterable { yield 'report static as self' => [ ' [ ' [ ' [ ' [ ' [ 'doTest($expected, $input); } public static function provideFix80Cases(): iterable { yield 'static' => [ ' [ ' [ ' [ ' [ ' */ function my_foo(): string|array {}', ' */ function my_foo() {}', ]; yield 'union types including nullable' => [ ' [ 'doTest($expected, $input); } public static function provideFixPre81Cases(): iterable { yield 'skip never type' => [ 'doTest($expected, $input); } public static function provideFix81Cases(): iterable { yield 'never type' => [ '