|
| 1 | +<?php declare(strict_types=1); |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of PHP CS Fixer: custom fixers. |
| 5 | + * |
| 6 | + * (c) 2018 Kuba Werłos |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view |
| 9 | + * the LICENSE file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Tests\Fixer; |
| 13 | + |
| 14 | +/** |
| 15 | + * @internal |
| 16 | + * |
| 17 | + * @covers \PhpCsFixerCustomFixers\Fixer\PhpdocTypesCommaSpacesFixer |
| 18 | + */ |
| 19 | +final class PhpdocTypesCommaSpacesFixerTest extends AbstractFixerTestCase |
| 20 | +{ |
| 21 | + public function testIsRisky(): void |
| 22 | + { |
| 23 | + self::assertFalse($this->fixer->isRisky()); |
| 24 | + } |
| 25 | + |
| 26 | + /** |
| 27 | + * @dataProvider provideFixCases |
| 28 | + */ |
| 29 | + public function testFix(string $expected, ?string $input = null): void |
| 30 | + { |
| 31 | + $this->doTest($expected, $input); |
| 32 | + } |
| 33 | + |
| 34 | + /** |
| 35 | + * @return iterable<array{0: string, 1?: string}> |
| 36 | + */ |
| 37 | + public static function provideFixCases(): iterable |
| 38 | + { |
| 39 | + yield ['<?php /** @var int $commaCount Number of "," in text. */']; |
| 40 | + |
| 41 | + yield [ |
| 42 | + '<?php /** @var array<int, string> */', |
| 43 | + '<?php /** @var array<int,string> */', |
| 44 | + ]; |
| 45 | + |
| 46 | + yield [ |
| 47 | + '<?php /** @var array<int, string> */', |
| 48 | + '<?php /** @var array<int , string> */', |
| 49 | + ]; |
| 50 | + |
| 51 | + yield [ |
| 52 | + '<?php |
| 53 | + /** @var array<int, string> $a */ |
| 54 | + /** @var array<int, string> $b */ |
| 55 | + /** @var array<int, string> $c */ |
| 56 | + /** @var array<int, string> $d */ |
| 57 | + ', |
| 58 | + '<?php |
| 59 | + /** @var array<int ,string> $a */ |
| 60 | + /** @var array<int, string> $b */ |
| 61 | + /** @var array<int, string> $c */ |
| 62 | + /** @var array<int , string> $d */ |
| 63 | + ', |
| 64 | + ]; |
| 65 | + |
| 66 | + yield [ |
| 67 | + '<?php /** |
| 68 | + * @param array<int, string> $a |
| 69 | + * @param array<int, string> $b |
| 70 | + * @param array<int, string> $c |
| 71 | + * @param array<int, array<int, array<int, string>>> $d |
| 72 | + */', |
| 73 | + '<?php /** |
| 74 | + * @param array<int,string> $a |
| 75 | + * @param array<int ,string> $b |
| 76 | + * @param array<int , string> $c |
| 77 | + * @param array<int , array<int , array<int , string>>> $d |
| 78 | + */', |
| 79 | + ]; |
| 80 | + |
| 81 | + yield [ |
| 82 | + '<?php /** |
| 83 | + * @return array< Foo, Bar, Baz > |
| 84 | + */', |
| 85 | + '<?php /** |
| 86 | + * @return array< Foo , Bar , Baz > |
| 87 | + */', |
| 88 | + ]; |
| 89 | + |
| 90 | + yield [ |
| 91 | + '<?php /** |
| 92 | + * The "," in here should not be touched |
| 93 | + * |
| 94 | + * @param array<int, int> $x Comma in type should be fixed, but this one: "," should not |
| 95 | + * @param array<int, int> $y Comma in type should be fixed, but this one: "," and "," should not |
| 96 | + * |
| 97 | + * @return array<string, Foo> Description having "," should not be touched |
| 98 | + */', |
| 99 | + '<?php /** |
| 100 | + * The "," in here should not be touched |
| 101 | + * |
| 102 | + * @param array<int,int> $x Comma in type should be fixed, but this one: "," should not |
| 103 | + * @param array<int , int> $y Comma in type should be fixed, but this one: "," and "," should not |
| 104 | + * |
| 105 | + * @return array<string,Foo> Description having "," should not be touched |
| 106 | + */', |
| 107 | + ]; |
| 108 | + } |
| 109 | +} |
0 commit comments