PhpdocNoEmptyReturnFixerTest.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <?php
  2. /*
  3. * This file is part of PHP CS Fixer.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. * Dariusz Rumiński <dariusz.ruminski@gmail.com>
  7. *
  8. * This source file is subject to the MIT license that is bundled
  9. * with this source code in the file LICENSE.
  10. */
  11. namespace PhpCsFixer\Tests\Fixer\Phpdoc;
  12. use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
  13. /**
  14. * @author Graham Campbell <graham@alt-three.com>
  15. *
  16. * @internal
  17. *
  18. * @covers \PhpCsFixer\Fixer\Phpdoc\PhpdocNoEmptyReturnFixer
  19. */
  20. final class PhpdocNoEmptyReturnFixerTest extends AbstractFixerTestCase
  21. {
  22. public function testFixVoid()
  23. {
  24. $expected = <<<'EOF'
  25. <?php
  26. /**
  27. */
  28. EOF;
  29. $input = <<<'EOF'
  30. <?php
  31. /**
  32. * @return void
  33. */
  34. EOF;
  35. $this->doTest($expected, $input);
  36. }
  37. public function testFixNull()
  38. {
  39. $expected = <<<'EOF'
  40. <?php
  41. /**
  42. */
  43. EOF;
  44. $input = <<<'EOF'
  45. <?php
  46. /**
  47. * @return null
  48. */
  49. EOF;
  50. $this->doTest($expected, $input);
  51. }
  52. public function testFixVoidCaseInsensitive()
  53. {
  54. $expected = <<<'EOF'
  55. <?php
  56. /**
  57. */
  58. EOF;
  59. $input = <<<'EOF'
  60. <?php
  61. /**
  62. * @return vOId
  63. */
  64. EOF;
  65. $this->doTest($expected, $input);
  66. }
  67. public function testFixNullCaseInsensitive()
  68. {
  69. $expected = <<<'EOF'
  70. <?php
  71. /**
  72. */
  73. EOF;
  74. $input = <<<'EOF'
  75. <?php
  76. /**
  77. * @return nULl
  78. */
  79. EOF;
  80. $this->doTest($expected, $input);
  81. }
  82. public function testFixFull()
  83. {
  84. $expected = <<<'EOF'
  85. <?php
  86. /**
  87. * Hello!
  88. *
  89. * @param string $foo
  90. */
  91. EOF;
  92. $input = <<<'EOF'
  93. <?php
  94. /**
  95. * Hello!
  96. *
  97. * @param string $foo
  98. * @return void
  99. */
  100. EOF;
  101. $this->doTest($expected, $input);
  102. }
  103. public function testDoNothing()
  104. {
  105. $expected = <<<'EOF'
  106. <?php
  107. /**
  108. * @var null
  109. */
  110. EOF;
  111. $this->doTest($expected);
  112. }
  113. public function testDoNothingAgain()
  114. {
  115. $expected = <<<'EOF'
  116. <?php
  117. /**
  118. * @return null|int
  119. */
  120. EOF;
  121. $this->doTest($expected);
  122. }
  123. public function testOtherDoNothing()
  124. {
  125. $expected = <<<'EOF'
  126. <?php
  127. /**
  128. * @return int|null
  129. */
  130. EOF;
  131. $this->doTest($expected);
  132. }
  133. public function testYetAnotherDoNothing()
  134. {
  135. $expected = <<<'EOF'
  136. <?php
  137. /**
  138. * @return null[]|string[]
  139. */
  140. EOF;
  141. $this->doTest($expected);
  142. }
  143. public function testHandleSingleLinePhpdoc()
  144. {
  145. $expected = <<<'EOF'
  146. <?php
  147. EOF;
  148. $input = <<<'EOF'
  149. <?php
  150. /** @return null */
  151. EOF;
  152. $this->doTest($expected, $input);
  153. }
  154. }