@Symfony.test-out.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. public 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. *
  29. * @param string $dummy Some argument description
  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 = [], $data = null)
  37. {
  38. $fnc = function () { return true; };
  39. $mergedOptions = array_merge(
  40. [
  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. *
  67. * @return string
  68. */
  69. private function printText($text)
  70. {
  71. echo $text;
  72. }
  73. }
  74. interface Test1Interface
  75. {
  76. }
  77. interface Test2Interface
  78. {
  79. }
  80. class FooBarTest extends \PHPUnit_Framework_TestCase implements Test1Interface, Test2Interface
  81. {
  82. /**
  83. * @expectedException \Exception
  84. */
  85. public function testFooBar($a)
  86. {
  87. $b = 1 === $a ? 'a' : 'b';
  88. echo $b;
  89. }
  90. }
  91. final class FinalClass
  92. {
  93. final public function finalMethod()
  94. {
  95. }
  96. }
  97. function callback($a, ...$b)
  98. {
  99. return (--$a) * ($b++);
  100. }
  101. $a = &$b;
  102. $c = &$d;
  103. echo 1;