NoMultilineWhitespaceAroundDoubleArrowFixerTest.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. yield [
  35. '<?php
  36. $arr = array(
  37. $a => array(1),
  38. $a => array(0 => array())
  39. );',
  40. '<?php
  41. $arr = array(
  42. $a =>
  43. array(1),
  44. $a =>
  45. array(0 =>
  46. array())
  47. );',
  48. ];
  49. yield [
  50. '<?php
  51. $a = array(
  52. "aaaaaa" => "b",
  53. "c" => "d",
  54. "eeeeee" => array(),
  55. "ggg" => array(),
  56. "hh" => [],
  57. );',
  58. '<?php
  59. $a = array(
  60. "aaaaaa" => "b",
  61. "c"
  62. =>
  63. "d",
  64. "eeeeee" => array(),
  65. "ggg" =>
  66. array(),
  67. "hh" =>
  68. [],
  69. );',
  70. ];
  71. yield [
  72. '<?php
  73. $hello = array(
  74. "foo" =>
  75. // hello there
  76. "value",
  77. "hi" =>
  78. /*
  79. * Description.
  80. */1,
  81. "ha" =>
  82. /**
  83. * Description.
  84. */
  85. array()
  86. );',
  87. ];
  88. yield [
  89. '<?php
  90. $fn = fn() => null;',
  91. '<?php
  92. $fn = fn()
  93. =>
  94. null;',
  95. ];
  96. yield [
  97. '<?php
  98. $foo = [
  99. 1 /* foo */ => $one,
  100. 2 => $two
  101. ];',
  102. '<?php
  103. $foo = [
  104. 1 /* foo */
  105. =>
  106. $one,
  107. 2
  108. =>
  109. $two
  110. ];',
  111. ];
  112. yield [
  113. '<?php
  114. $foo = [
  115. 1 // foo
  116. => $one,
  117. 2 => $two,
  118. ];',
  119. '<?php
  120. $foo = [
  121. 1 // foo
  122. =>
  123. $one,
  124. 2
  125. =>
  126. $two,
  127. ];',
  128. ];
  129. }
  130. }