* 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\Tests\Test\AbstractFixerTestCase; /** * @author Gert de Pagter * * @internal * * @covers \PhpCsFixer\Fixer\Phpdoc\PhpdocLineSpanFixer * * @extends AbstractFixerTestCase<\PhpCsFixer\Fixer\Phpdoc\PhpdocLineSpanFixer> * * @phpstan-import-type _AutogeneratedInputConfiguration from \PhpCsFixer\Fixer\Phpdoc\PhpdocLineSpanFixer */ final class PhpdocLineSpanFixerTest extends AbstractFixerTestCase { /** * @dataProvider provideFixCases * * @param _AutogeneratedInputConfiguration $config */ 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 'It does not change doc blocks if not needed' => [ ' [ ' [ ' 'single', 'const' => 'single', 'method' => 'single', ], ]; yield 'It does change complicated doc blocks to single if configured to do so' => [ ' 'single', ], ]; yield 'It does not changes doc blocks from single if configured to do so' => [ ' 'single', 'const' => 'single', 'method' => 'single', ], ]; yield 'It can be configured to change certain elements to single line' => [ ' 'single', ], ]; yield 'It wont change a doc block to single line if it has multiple useful lines' => [ ' 'single', ], ]; yield 'It updates doc blocks correctly, even with more indentation' => [ ' 'single', ], ]; yield 'It can convert empty doc blocks' => [ ' 'single', ], ]; yield 'It can update doc blocks of static properties' => [ ' [ ' [ ' [ ' null, ], ]; yield 'It does not change property doc blocks if configured to do so' => [ ' null, ], ]; yield 'It does not change const doc blocks if configured to do so' => [ ' null, ], ]; yield 'It can handle constants with visibility, does not crash on trait imports' => [ ' 'single', ], ]; yield 'It can handle properties with type declaration' => [ ' 'single', ], ]; yield 'It can handle properties with array type declaration' => [ ' 'single', ], ]; } /** * @dataProvider provideFix80Cases * * @requires PHP 8.0 * * @param _AutogeneratedInputConfiguration $config */ public function testFix80(string $expected, ?string $input = null, array $config = []): void { $this->fixer->configure($config); $this->doTest($expected, $input); } public static function provideFix80Cases(): iterable { yield 'It detects attributes between docblock and token' => [ ' 'single', ], ]; yield 'It handles class constants correctly' => [ ' [ 'fixer->configure($config); $this->doTest($expected, $input); } public static function provideFix81Cases(): iterable { yield 'It handles readonly properties correctly' => [ ' 'single', ], ]; yield 'It handles class constant correctly' => [ ' [ ' [ 'doTest($expected, $input); } /** * @return iterable */ public static function provideFix82Cases(): iterable { yield 'constant in trait' => [ <<<'PHP'