NoMultilineWhitespaceAroundDoubleArrowFixerTest.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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\ArrayNotation;
  13. use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
  14. /**
  15. * @author Carlos Cirello <carlos.cirello.nl@gmail.com>
  16. * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
  17. * @author Graham Campbell <hello@gjcampbell.co.uk>
  18. *
  19. * @internal
  20. *
  21. * @covers \PhpCsFixer\Fixer\ArrayNotation\NoMultilineWhitespaceAroundDoubleArrowFixer
  22. */
  23. final class NoMultilineWhitespaceAroundDoubleArrowFixerTest extends AbstractFixerTestCase
  24. {
  25. /**
  26. * @dataProvider provideFixCases
  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. return [
  35. [
  36. '<?php
  37. $arr = array(
  38. $a => array(1),
  39. $a => array(0 => array())
  40. );',
  41. '<?php
  42. $arr = array(
  43. $a =>
  44. array(1),
  45. $a =>
  46. array(0 =>
  47. array())
  48. );',
  49. ],
  50. [
  51. '<?php
  52. $a = array(
  53. "aaaaaa" => "b",
  54. "c" => "d",
  55. "eeeeee" => array(),
  56. "ggg" => array(),
  57. "hh" => [],
  58. );',
  59. '<?php
  60. $a = array(
  61. "aaaaaa" => "b",
  62. "c"
  63. =>
  64. "d",
  65. "eeeeee" => array(),
  66. "ggg" =>
  67. array(),
  68. "hh" =>
  69. [],
  70. );',
  71. ],
  72. [
  73. '<?php
  74. $hello = array(
  75. "foo" =>
  76. // hello there
  77. "value",
  78. "hi" =>
  79. /*
  80. * Description.
  81. */1,
  82. "ha" =>
  83. /**
  84. * Description.
  85. */
  86. array()
  87. );',
  88. ],
  89. [
  90. '<?php
  91. $fn = fn() => null;',
  92. '<?php
  93. $fn = fn()
  94. =>
  95. null;',
  96. ],
  97. [
  98. '<?php
  99. $foo = [
  100. 1 /* foo */ => $one,
  101. 2 => $two
  102. ];',
  103. '<?php
  104. $foo = [
  105. 1 /* foo */
  106. =>
  107. $one,
  108. 2
  109. =>
  110. $two
  111. ];',
  112. ],
  113. [
  114. '<?php
  115. $foo = [
  116. 1 // foo
  117. => $one,
  118. 2 => $two,
  119. ];',
  120. '<?php
  121. $foo = [
  122. 1 // foo
  123. =>
  124. $one,
  125. 2
  126. =>
  127. $two,
  128. ];',
  129. ],
  130. ];
  131. }
  132. }