PhpdocTrimConsecutiveBlankLineSeparationFixerTest.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. final class PhpdocTrimConsecutiveBlankLineSeparationFixerTest extends AbstractFixerTestCase
  23. {
  24. /**
  25. * @dataProvider provideFixCases
  26. */
  27. public function testFix(string $expected, ?string $input = null): void
  28. {
  29. $this->doTest($expected, $input);
  30. }
  31. public static function provideFixCases(): iterable
  32. {
  33. yield 'no changes' => ['<?php /** Summary. */'];
  34. yield 'only Summary and Description' => [
  35. '<?php
  36. /**
  37. * Summary.
  38. *
  39. * Description.
  40. *
  41. *
  42. *
  43. */',
  44. '<?php
  45. /**
  46. * Summary.
  47. *
  48. *
  49. * Description.
  50. *
  51. *
  52. *
  53. */',
  54. ];
  55. yield 'basic phpdoc' => [
  56. '<?php
  57. /**
  58. * Summary.
  59. *
  60. * Description.
  61. *
  62. * @var int
  63. *
  64. * @return int
  65. *
  66. * foo
  67. *
  68. * bar
  69. *
  70. *
  71. */',
  72. '<?php
  73. /**
  74. * Summary.
  75. *
  76. *
  77. * Description.
  78. *
  79. *
  80. * @var int
  81. *
  82. *
  83. *
  84. *
  85. * @return int
  86. *
  87. *
  88. * foo
  89. *
  90. *
  91. * bar
  92. *
  93. *
  94. */',
  95. ];
  96. yield 'extra blank lines in description' => [
  97. '<?php
  98. /**
  99. * Summary.
  100. *
  101. * Description has multiple blank lines:
  102. *
  103. *
  104. *
  105. * End.
  106. *
  107. * @var int
  108. */',
  109. ];
  110. yield 'extra blank lines after annotation' => [
  111. '<?php
  112. /**
  113. * Summary without description.
  114. *
  115. * @var int
  116. *
  117. * This is still @var annotation description...
  118. *
  119. * But this is not!
  120. *
  121. * @internal
  122. */',
  123. '<?php
  124. /**
  125. * Summary without description.
  126. *
  127. *
  128. * @var int
  129. *
  130. * This is still @var annotation description...
  131. *
  132. *
  133. *
  134. *
  135. * But this is not!
  136. *
  137. *
  138. *
  139. *
  140. *
  141. * @internal
  142. */',
  143. ];
  144. yield 'extra blank lines between annotations when no Summary no Description' => [
  145. '<?php
  146. /**
  147. * @param string $expected
  148. * @param string $input
  149. *
  150. * @dataProvider provideFix56Cases
  151. */',
  152. '<?php
  153. /**
  154. * @param string $expected
  155. * @param string $input
  156. *
  157. *
  158. * @dataProvider provideFix56Cases
  159. */',
  160. ];
  161. }
  162. }