FunctionDeclarationFixerTest.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. /*
  3. * This file is part of the PHP CS utility.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. namespace Symfony\CS\Tests\Fixer\PSR2;
  11. use Symfony\CS\Tests\Fixer\AbstractFixerTestBase;
  12. /**
  13. * @author Denis Sokolov <denis@sokolov.cc>
  14. * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
  15. */
  16. class FunctionDeclarationFixerTest extends AbstractFixerTestBase
  17. {
  18. /**
  19. * @dataProvider provideCases
  20. */
  21. public function testFix($expected, $input = null)
  22. {
  23. $this->makeTest($expected, $input);
  24. }
  25. public function provideCases()
  26. {
  27. return array(
  28. array(
  29. // non-PHP test
  30. 'function foo () {}',
  31. ),
  32. array(
  33. '<?php function foo() {}',
  34. '<?php function foo() {}',
  35. ),
  36. array(
  37. '<?php function foo() {}',
  38. '<?php function foo () {}',
  39. ),
  40. array(
  41. '<?php function foo() {}',
  42. '<?php function foo () {}',
  43. ),
  44. array(
  45. '<?php function foo() {}',
  46. '<?php function
  47. foo () {}',
  48. ),
  49. array(
  50. '<?php function ($i) {};',
  51. '<?php function($i) {};',
  52. ),
  53. array(
  54. '<?php function _function() {}',
  55. '<?php function _function () {}',
  56. ),
  57. array(
  58. '<?php function foo($a, $b = true) {}',
  59. '<?php function foo($a, $b = true){}',
  60. ),
  61. array(
  62. '<?php function foo($a, $b = true) {}',
  63. '<?php function foo($a, $b = true) {}',
  64. ),
  65. array(
  66. '<?php function foo($a)
  67. {}',
  68. ),
  69. array(
  70. '<?php function ($a) use ($b) {};',
  71. '<?php function ($a) use ($b) {};',
  72. ),
  73. array(
  74. '<?php function &foo($a) {}',
  75. '<?php function &foo( $a ) {}',
  76. ),
  77. array(
  78. '<?php function foo($a)
  79. {}',
  80. '<?php function foo( $a)
  81. {}',
  82. ),
  83. array(
  84. '<?php
  85. function foo(
  86. $a,
  87. $b,
  88. $c
  89. ) {}',
  90. ),
  91. array(
  92. '<?php $function = function () {};',
  93. '<?php $function = function(){};',
  94. ),
  95. array(
  96. '<?php $function("");',
  97. ),
  98. array(
  99. '<?php function ($a) use ($b) {};',
  100. '<?php function($a)use($b) {};',
  101. ),
  102. array(
  103. '<?php function ($a) use ($b) {};',
  104. '<?php function($a) use ($b) {};',
  105. ),
  106. array(
  107. '<?php function ($a) use ($b) {};',
  108. '<?php function ($a) use ( $b ) {};',
  109. ),
  110. array(
  111. '<?php function &($a) use ($b) {};',
  112. '<?php function &( $a ) use ( $b ) {};',
  113. ),
  114. array(
  115. '<?php
  116. interface Foo
  117. {
  118. public function setConfig(ConfigInterface $config);
  119. }',
  120. ),
  121. );
  122. }
  123. }