PhpdocSingleLineVarSpacingFixerTest.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. * @internal
  16. *
  17. * @covers \PhpCsFixer\Fixer\Phpdoc\PhpdocSingleLineVarSpacingFixer
  18. *
  19. * @extends AbstractFixerTestCase<\PhpCsFixer\Fixer\Phpdoc\PhpdocSingleLineVarSpacingFixer>
  20. */
  21. final class PhpdocSingleLineVarSpacingFixerTest extends AbstractFixerTestCase
  22. {
  23. /**
  24. * @dataProvider provideFixCases
  25. */
  26. public function testFix(string $expected, ?string $input = null): void
  27. {
  28. $this->doTest($expected, $input);
  29. }
  30. /**
  31. * @return iterable<array{0: string, 1?: string}>
  32. */
  33. public static function provideFixCases(): iterable
  34. {
  35. yield [
  36. '<?php
  37. class A {
  38. /** @var MyCass6 $a */
  39. public $test6 = 6;
  40. /** @var MyCass6 */
  41. public $testB = 7;
  42. }
  43. ',
  44. '<?php
  45. class A {
  46. /**@var MyCass6 $a */
  47. public $test6 = 6;
  48. /**@var MyCass6*/
  49. public $testB = 7;
  50. }
  51. ',
  52. ];
  53. yield [
  54. '<?php
  55. /** @var MyCass1 $test1 description and more. */
  56. $test0 = 1;
  57. /** @var MyCass2 description and such. */
  58. $test1 = 2;
  59. /** @var MyCass3 description. */
  60. $test2 = 3;
  61. class A {
  62. /** @var MyCass4 aa */
  63. public $test4 = 4;
  64. /** @var MyCass5 */
  65. public $test5 = 5;
  66. /** @var MyCass6 */
  67. public $test6 = 6;
  68. }
  69. ',
  70. '<?php
  71. /** @var MyCass1 $test1 description and more.*/
  72. $test0 = 1;
  73. /** @var MyCass2 description and such. */
  74. $test1 = 2;
  75. /** @var MyCass3 description. */
  76. $test2 = 3;
  77. class A {
  78. /** @var MyCass4 aa */
  79. public $test4 = 4;
  80. /** @var MyCass5 */
  81. public $test5 = 5;
  82. /** @var MyCass6*/
  83. public $test6 = 6;
  84. }
  85. ',
  86. ];
  87. yield [
  88. '<?php
  89. class A
  90. {
  91. /**
  92. * @param array $options {
  93. * @var bool $required Whether this element is required
  94. * @var string $label The display name for this element
  95. * }
  96. */
  97. public function __construct(array $options = array())
  98. {
  99. }
  100. /**
  101. * @var bool $required Whether this element is required
  102. * @var string $label The display name for this element
  103. */
  104. public function test($required, $label)
  105. {
  106. }
  107. /** @var MyCass3
  108. */
  109. private $test0 = 0;
  110. }',
  111. ];
  112. }
  113. }