NoTrailingCommaInListCallFixerTest.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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\ControlStructure;
  13. use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
  14. /**
  15. * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
  16. *
  17. * @internal
  18. *
  19. * @covers \PhpCsFixer\Fixer\ControlStructure\NoTrailingCommaInListCallFixer
  20. */
  21. final class NoTrailingCommaInListCallFixerTest extends AbstractFixerTestCase
  22. {
  23. /**
  24. * @dataProvider provideFixCases
  25. */
  26. public function testFix(string $expected, ?string $input = null): void
  27. {
  28. $this->doTest($expected, $input);
  29. }
  30. public static function provideFixCases(): iterable
  31. {
  32. yield [
  33. '<?php
  34. list($a, $b) = foo();
  35. list($a, , $c, $d) = foo();
  36. list($a, , $c) = foo();
  37. list($a) = foo();
  38. list($a , $b) = foo();
  39. list($a, /* $b */, $c) = foo();
  40. ',
  41. '<?php
  42. list($a, $b) = foo();
  43. list($a, , $c, $d, ) = foo();
  44. list($a, , $c, , ) = foo();
  45. list($a, , , , , ) = foo();
  46. list($a , $b , ) = foo();
  47. list($a, /* $b */, $c, ) = foo();
  48. ',
  49. ];
  50. yield [
  51. '<?php
  52. list(
  53. $a#
  54. ,#
  55. #
  56. ) = $a;',
  57. ];
  58. }
  59. }