* 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\Phpdoc; use PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException; use PhpCsFixer\Tests\Test\AbstractFixerTestCase; /** * @author Graham Campbell * @author Dariusz Rumiński * * @internal * * @covers \PhpCsFixer\AbstractPhpdocTypesFixer * @covers \PhpCsFixer\Fixer\Phpdoc\PhpdocTypesFixer * * @extends AbstractFixerTestCase<\PhpCsFixer\Fixer\Phpdoc\PhpdocTypesFixer> * * @phpstan-import-type _AutogeneratedInputConfiguration from \PhpCsFixer\Fixer\Phpdoc\PhpdocTypesFixer */ final class PhpdocTypesFixerTest extends AbstractFixerTestCase { /** * @dataProvider provideFixCases * * @param _AutogeneratedInputConfiguration $configuration */ public function testFix(string $expected, ?string $input = null, array $configuration = []): void { $this->fixer->configure($configuration); $this->doTest($expected, $input); } public static function provideFixCases(): iterable { yield 'windows line breaks' => [ " [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' ['simple', 'meta']], ]; yield 'generics' => [ ' $a * @param array $b * @param array $c * @param iterable $thisShouldNotBeChanged * @param iterable $thisShouldNotBeChangedNeither * * @return array>> */', ' $a * @param ARRAY $b * @param array $c * @param iterable $thisShouldNotBeChanged * @param iterable $thisShouldNotBeChangedNeither * * @return ARRAY>> */', ['groups' => ['simple', 'meta']], ]; yield 'callable' => [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' $value */', ' $value */', ]; yield 'param with extra parentheses' => [ ' [ ' [ 'expectException(InvalidFixerConfigurationException::class); $this->expectExceptionMessageMatches('/^\[phpdoc_types\] Invalid configuration: The option "groups" .*\.$/'); $this->fixer->configure(['groups' => ['__TEST__']]); // @phpstan-ignore-line } }