DeclareParenthesesFixerTest.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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\LanguageConstruct;
  13. use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
  14. /**
  15. * @internal
  16. *
  17. * @covers \PhpCsFixer\Fixer\LanguageConstruct\DeclareParenthesesFixer
  18. *
  19. * @extends AbstractFixerTestCase<\PhpCsFixer\Fixer\LanguageConstruct\DeclareParenthesesFixer>
  20. */
  21. final class DeclareParenthesesFixerTest 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. /**
  31. * @return iterable<string, array{string, string}>
  32. */
  33. public static function provideFixCases(): iterable
  34. {
  35. yield 'spaces around parentheses' => [
  36. '<?php declare(strict_types = 1);',
  37. '<?php declare ( strict_types = 1 );',
  38. ];
  39. yield 'newlines (\n) around parentheses' => [
  40. '<?php declare(strict_types = 1);',
  41. '<?php declare
  42. (
  43. strict_types = 1
  44. );',
  45. ];
  46. yield 'newlines (\r\n) around parentheses' => [
  47. '<?php declare(strict_types = 1);',
  48. "<?php declare\r
  49. (\r
  50. strict_types = 1\r
  51. );",
  52. ];
  53. }
  54. }