NoMultilineWhitespaceAroundDoubleArrowFixerTest.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 function provideFixCases(): array
  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. }
  91. /**
  92. * @dataProvider provideFixPhp74Cases
  93. * @requires PHP 7.4
  94. */
  95. public function testFixPhp74(string $expected, ?string $input = null): void
  96. {
  97. $this->doTest($expected, $input);
  98. }
  99. public function provideFixPhp74Cases(): array
  100. {
  101. return [
  102. [
  103. '<?php
  104. $fn = fn() => null;',
  105. '<?php
  106. $fn = fn()
  107. =>
  108. null;',
  109. ],
  110. ];
  111. }
  112. }