PhpdocSingleLineVarSpacingFixerTest.php 3.2 KB

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