PhpdocTrimConsecutiveBlankLineSeparationFixerTest.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * This file is part of PHP CS Fixer.
  5. *
  6. * (c) Fabien Potencier <fabien@symfony.com>
  7. * Dariusz Rumiński <dariusz.ruminski@gmail.com>
  8. *
  9. * This source file is subject to the MIT license that is bundled
  10. * with this source code in the file LICENSE.
  11. */
  12. namespace PhpCsFixer\Tests\Fixer\Phpdoc;
  13. use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
  14. /**
  15. * @author Nobu Funaki <nobu.funaki@gmail.com>
  16. * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
  17. *
  18. * @internal
  19. *
  20. * @covers \PhpCsFixer\Fixer\Phpdoc\PhpdocTrimConsecutiveBlankLineSeparationFixer
  21. *
  22. * @extends AbstractFixerTestCase<\PhpCsFixer\Fixer\Phpdoc\PhpdocTrimConsecutiveBlankLineSeparationFixer>
  23. */
  24. final class PhpdocTrimConsecutiveBlankLineSeparationFixerTest extends AbstractFixerTestCase
  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. * @return iterable<string, array{0: string, 1?: string}>
  35. */
  36. public static function provideFixCases(): iterable
  37. {
  38. yield 'no changes' => ['<?php /** Summary. */'];
  39. yield 'only Summary and Description' => [
  40. '<?php
  41. /**
  42. * Summary.
  43. *
  44. * Description.
  45. *
  46. *
  47. *
  48. */',
  49. '<?php
  50. /**
  51. * Summary.
  52. *
  53. *
  54. * Description.
  55. *
  56. *
  57. *
  58. */',
  59. ];
  60. yield 'basic phpdoc' => [
  61. '<?php
  62. /**
  63. * Summary.
  64. *
  65. * Description.
  66. *
  67. * @var int
  68. *
  69. * @return int
  70. *
  71. * foo
  72. *
  73. * bar
  74. *
  75. *
  76. */',
  77. '<?php
  78. /**
  79. * Summary.
  80. *
  81. *
  82. * Description.
  83. *
  84. *
  85. * @var int
  86. *
  87. *
  88. *
  89. *
  90. * @return int
  91. *
  92. *
  93. * foo
  94. *
  95. *
  96. * bar
  97. *
  98. *
  99. */',
  100. ];
  101. yield 'extra blank lines in description' => [
  102. '<?php
  103. /**
  104. * Summary.
  105. *
  106. * Description has multiple blank lines:
  107. *
  108. *
  109. *
  110. * End.
  111. *
  112. * @var int
  113. */',
  114. ];
  115. yield 'extra blank lines after annotation' => [
  116. '<?php
  117. /**
  118. * Summary without description.
  119. *
  120. * @var int
  121. *
  122. * This is still @var annotation description...
  123. *
  124. * But this is not!
  125. *
  126. * @internal
  127. */',
  128. '<?php
  129. /**
  130. * Summary without description.
  131. *
  132. *
  133. * @var int
  134. *
  135. * This is still @var annotation description...
  136. *
  137. *
  138. *
  139. *
  140. * But this is not!
  141. *
  142. *
  143. *
  144. *
  145. *
  146. * @internal
  147. */',
  148. ];
  149. yield 'extra blank lines between annotations when no Summary no Description' => [
  150. '<?php
  151. /**
  152. * @param string $expected
  153. * @param string $input
  154. *
  155. * @dataProvider provideFix56Cases
  156. */',
  157. '<?php
  158. /**
  159. * @param string $expected
  160. * @param string $input
  161. *
  162. *
  163. * @dataProvider provideFix56Cases
  164. */',
  165. ];
  166. }
  167. }