@Symfony_whitespaces.test-in.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Acme;
  11. declare(ticks=1);
  12. /**
  13. * Coding standards demonstration.
  14. */
  15. class FooBar
  16. {
  17. const SOME_CONST = 42;
  18. private $fooBar;
  19. /**
  20. * @param string $dummy Some argument description
  21. */
  22. public function __construct($dummy)
  23. {{
  24. $this->fooBar = $this->transformText($dummy);
  25. }}
  26. /**
  27. * Foo
  28. * @param string $dummy Some argument description
  29. * @param array $options
  30. * @param string|null $data Foo
  31. *
  32. * @return string|null Transformed input
  33. *
  34. * @throws \RuntimeException
  35. */
  36. private function transformText($dummy, array $options = array(),$data=null)
  37. {
  38. $fnc = function () { return true; };
  39. $mergedOptions = array_merge(
  40. array(
  41. 'some_default' => 'values',
  42. 'another_default' => 'more values',
  43. ),
  44. $options
  45. );
  46. if (true === $dummy) {
  47. return;
  48. }
  49. if ('string' === $dummy) {
  50. if ('values' === $mergedOptions['some_default']) {
  51. return substr($dummy, 0, 5);
  52. }
  53. return ucwords($dummy);
  54. }
  55. throw new \RuntimeException(sprintf('Unrecognized dummy option "%s"', $dummy));
  56. }
  57. private function reverseBoolean($value = null, $theSwitch = false)
  58. {
  59. if (!$theSwitch) {
  60. return;
  61. }
  62. return !$value;
  63. }
  64. /**
  65. * @param string $text
  66. * @return string
  67. */
  68. private function printText($text)
  69. {
  70. echo $text;
  71. }
  72. }
  73. interface Test1Interface
  74. {
  75. }
  76. interface Test2Interface
  77. {
  78. }
  79. class FooBarTest extends
  80. \PHPUnit_Framework_TestCase
  81. implements
  82. Test1Interface,
  83. Test2Interface
  84. {
  85. /**
  86. * @expectedException Exception
  87. */
  88. public function testFooBar($a)
  89. {
  90. $b = $a === 1 ? 'a' : 'b';
  91. echo $b;;
  92. }
  93. }
  94. final class FinalClass
  95. {
  96. final function finalMethod(){}
  97. }
  98. echo 1 ?>