@PER-CS2.0.test-out.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace Vendor\Package;
  3. use FooInterfaceA;
  4. use FooInterfaceB;
  5. use BarClass as Bar;
  6. use OtherVendor\OtherPackage\BazClass;
  7. use function foo;
  8. use const BAR;
  9. class Foo extends Bar implements FooInterfaceA
  10. {
  11. use FooTrait;
  12. use BarTrait;
  13. public $aaa = 1;
  14. public $bbb = 2;
  15. public function sampleFunction($a, $arg1, $arg2, $arg3, $foo, $b = null)
  16. {
  17. if ($a === $b) {
  18. bar();
  19. } elseif ($a > $b) {
  20. $foo->bar($arg1);
  21. } else {
  22. BazClass::bar($arg2, $arg3);
  23. }
  24. $combined = $a . $b;
  25. static::baz();
  26. }
  27. final public static function bar()
  28. {
  29. // method body
  30. }
  31. }
  32. class Aaa implements
  33. Bbb,
  34. Ccc,
  35. Ddd {}
  36. $a = new Foo();
  37. $b = (bool) 1;
  38. $c = true ? (int) '1' : 2;
  39. $anonymousClass = new class {
  40. public function test()
  41. {
  42. // method body
  43. }
  44. };
  45. $fn = fn($a) => $a;
  46. $arrayNotMultiline = ['foo' => 'bar', 'foo2' => 'bar'];
  47. $arrayMultiline = [
  48. 'foo' => 'bar',
  49. 'foo2' => 'bar',
  50. ];
  51. $arrayMultilineWithoutComma = [
  52. 'foo' => 'bar',
  53. 'foo2' => 'bar',
  54. ];
  55. $heredocMultilineWithoutComma = [
  56. 'foo',
  57. <<<EOD
  58. bar
  59. EOD,
  60. ];
  61. argumentsMultilineWithoutComma(
  62. 1,
  63. 2,
  64. );