PhpdocNoEmptyReturnFixerTest.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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 Graham Campbell <hello@gjcampbell.co.uk>
  16. *
  17. * @internal
  18. *
  19. * @covers \PhpCsFixer\Fixer\Phpdoc\PhpdocNoEmptyReturnFixer
  20. *
  21. * @extends AbstractFixerTestCase<\PhpCsFixer\Fixer\Phpdoc\PhpdocNoEmptyReturnFixer>
  22. */
  23. final class PhpdocNoEmptyReturnFixerTest extends AbstractFixerTestCase
  24. {
  25. public function testFixVoid(): void
  26. {
  27. $expected = <<<'EOF'
  28. <?php
  29. /**
  30. */
  31. EOF;
  32. $input = <<<'EOF'
  33. <?php
  34. /**
  35. * @return void
  36. */
  37. EOF;
  38. $this->doTest($expected, $input);
  39. }
  40. public function testFixNull(): void
  41. {
  42. $expected = <<<'EOF'
  43. <?php
  44. /**
  45. */
  46. EOF;
  47. $input = <<<'EOF'
  48. <?php
  49. /**
  50. * @return null
  51. */
  52. EOF;
  53. $this->doTest($expected, $input);
  54. }
  55. public function testFixNullWithEndOnSameLine(): void
  56. {
  57. $expected = <<<'EOF'
  58. <?php
  59. /**
  60. */
  61. EOF;
  62. $input = <<<'EOF'
  63. <?php
  64. /**
  65. * @return null */
  66. EOF;
  67. $this->doTest($expected, $input);
  68. }
  69. public function testFixNullWithEndOnSameLineNoSpace(): void
  70. {
  71. $expected = <<<'EOF'
  72. <?php
  73. /**
  74. */
  75. EOF;
  76. $input = <<<'EOF'
  77. <?php
  78. /**
  79. * @return null*/
  80. EOF;
  81. $this->doTest($expected, $input);
  82. }
  83. public function testFixVoidCaseInsensitive(): void
  84. {
  85. $expected = <<<'EOF'
  86. <?php
  87. /**
  88. */
  89. EOF;
  90. $input = <<<'EOF'
  91. <?php
  92. /**
  93. * @return vOId
  94. */
  95. EOF;
  96. $this->doTest($expected, $input);
  97. }
  98. public function testFixNullCaseInsensitive(): void
  99. {
  100. $expected = <<<'EOF'
  101. <?php
  102. /**
  103. */
  104. EOF;
  105. $input = <<<'EOF'
  106. <?php
  107. /**
  108. * @return nULl
  109. */
  110. EOF;
  111. $this->doTest($expected, $input);
  112. }
  113. public function testFixFull(): void
  114. {
  115. $expected = <<<'EOF'
  116. <?php
  117. /**
  118. * Hello!
  119. *
  120. * @param string $foo
  121. */
  122. EOF;
  123. $input = <<<'EOF'
  124. <?php
  125. /**
  126. * Hello!
  127. *
  128. * @param string $foo
  129. * @return void
  130. */
  131. EOF;
  132. $this->doTest($expected, $input);
  133. }
  134. public function testDoNothing(): void
  135. {
  136. $expected = <<<'EOF'
  137. <?php
  138. /**
  139. * @var null
  140. */
  141. EOF;
  142. $this->doTest($expected);
  143. }
  144. public function testDoNothingAgain(): void
  145. {
  146. $expected = <<<'EOF'
  147. <?php
  148. /**
  149. * @return null|int
  150. */
  151. EOF;
  152. $this->doTest($expected);
  153. }
  154. public function testOtherDoNothing(): void
  155. {
  156. $expected = <<<'EOF'
  157. <?php
  158. /**
  159. * @return int|null
  160. */
  161. EOF;
  162. $this->doTest($expected);
  163. }
  164. public function testYetAnotherDoNothing(): void
  165. {
  166. $expected = <<<'EOF'
  167. <?php
  168. /**
  169. * @return null[]|string[]
  170. */
  171. EOF;
  172. $this->doTest($expected);
  173. }
  174. public function testHandleSingleLinePhpdoc(): void
  175. {
  176. $expected = <<<'EOF'
  177. <?php
  178. EOF;
  179. $input = <<<'EOF'
  180. <?php
  181. /** @return null */
  182. EOF;
  183. $this->doTest($expected, $input);
  184. }
  185. }