* 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 Jan Gantzert * * @internal * * @covers \PhpCsFixer\Fixer\FunctionNotation\PhpdocToParamTypeFixer */ final class PhpdocToParamTypeFixerTest extends AbstractFixerTestCase { /** * @dataProvider provideFixCases */ public function testFix(string $expected, ?string $input = null, ?int $versionSpecificFix = null, array $config = null): void { if ( null !== $input && ( \PHP_VERSION_ID < 70000 || (null !== $versionSpecificFix && \PHP_VERSION_ID < $versionSpecificFix) ) ) { $expected = $input; $input = null; } if (null !== $config) { $this->fixer->configure($config); } $this->doTest($expected, $input); } public function provideFixCases(): array { return [ 'typehint already defined' => [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' $foo */ function my_foo(array $foo) {}', ' $foo */ function my_foo($foo) {}', ], 'generics with multiple types' => [ ' $foo */ function my_foo(array $foo) {}', ' $foo */ function my_foo($foo) {}', ], 'stop searching last token' => [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' false], ], 'do not fix function call' => [ ' [ '