PhpdocReadonlyClassCommentToKeywordFixerTest.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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\ClassNotation;
  13. use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
  14. /**
  15. * @author Marcel Behrmann <marcel@behrmann.dev>
  16. *
  17. * @internal
  18. *
  19. * @covers \PhpCsFixer\Fixer\ClassNotation\PhpdocReadonlyClassCommentToKeywordFixer
  20. */
  21. final class PhpdocReadonlyClassCommentToKeywordFixerTest extends AbstractFixerTestCase
  22. {
  23. /**
  24. * @dataProvider provideFixCases
  25. *
  26. * @requires PHP 8.2
  27. */
  28. public function testFix(string $expected, ?string $input = null): void
  29. {
  30. $this->doTest($expected, $input);
  31. }
  32. public static function provideFixCases(): iterable
  33. {
  34. yield [
  35. <<<'EOT'
  36. <?php
  37. readonly class C {
  38. }
  39. EOT,
  40. <<<'EOT'
  41. <?php
  42. /** @readonly */
  43. class C {
  44. }
  45. EOT,
  46. ];
  47. yield [
  48. <<<'EOT'
  49. <?php
  50. /**
  51. */
  52. readonly class C {
  53. }
  54. EOT,
  55. <<<'EOT'
  56. <?php
  57. /**
  58. * @readonly
  59. */
  60. class C {
  61. }
  62. EOT,
  63. ];
  64. yield [
  65. <<<'EOT'
  66. <?php
  67. /**
  68. * Very impressive class
  69. *
  70. */
  71. readonly class C {
  72. }
  73. EOT,
  74. <<<'EOT'
  75. <?php
  76. /**
  77. * Very impressive class
  78. *
  79. * @readonly
  80. */
  81. class C {
  82. }
  83. EOT,
  84. ];
  85. yield [
  86. <<<'EOT'
  87. <?php
  88. /**
  89. */
  90. final readonly class C {
  91. }
  92. EOT,
  93. <<<'EOT'
  94. <?php
  95. /**
  96. * @readonly
  97. */
  98. final class C {
  99. }
  100. EOT,
  101. ];
  102. yield [
  103. <<<'EOT'
  104. <?php
  105. /**
  106. */
  107. abstract readonly class C {
  108. }
  109. EOT,
  110. <<<'EOT'
  111. <?php
  112. /**
  113. * @readonly
  114. */
  115. abstract class C {
  116. }
  117. EOT,
  118. ];
  119. yield [
  120. <<<'EOT'
  121. <?php
  122. /**
  123. */
  124. readonly class A {
  125. }
  126. EOT,
  127. <<<'EOT'
  128. <?php
  129. /**
  130. * @readonly
  131. */
  132. readonly class A {
  133. }
  134. EOT,
  135. ];
  136. yield [
  137. <<<'EOT'
  138. <?php
  139. /** Class A. */
  140. class A {
  141. }
  142. EOT,
  143. ];
  144. }
  145. }