PhpdocSingleLineVarSpacingFixerTest.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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 SpacePossum
  15. *
  16. * @internal
  17. *
  18. * @covers \PhpCsFixer\Fixer\Phpdoc\PhpdocSingleLineVarSpacingFixer
  19. */
  20. final class PhpdocSingleLineVarSpacingFixerTest extends AbstractFixerTestCase
  21. {
  22. /**
  23. * @param string $expected
  24. * @param null|string $input
  25. *
  26. * @dataProvider provideFixCases
  27. */
  28. public function testFix($expected, $input = null)
  29. {
  30. $this->doTest($expected, $input);
  31. }
  32. public function provideFixCases()
  33. {
  34. return [
  35. [
  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. [
  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. [
  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. }
  114. }