TestCaseUtils.php 850 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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\Test;
  13. /**
  14. * @internal
  15. */
  16. final class TestCaseUtils
  17. {
  18. /**
  19. * @param iterable<array{0: string, 1?: string}> $cases
  20. *
  21. * @return iterable<array{0: string, 1?: string}>
  22. */
  23. public static function swapExpectedInputTestCases(iterable $cases): iterable
  24. {
  25. foreach ($cases as $case) {
  26. if (1 === \count($case)) {
  27. yield $case;
  28. continue;
  29. }
  30. [$case[0], $case[1]] = [$case[1], $case[0]];
  31. yield $case;
  32. }
  33. }
  34. }