default.txt 981 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. function testBefore(<Test> a, var b = 5, int c = 10)
  2. {
  3. a->method1();
  4. return b + c;
  5. }
  6. namespace Test;
  7. use RuntimeException as RE;
  8. /**
  9. * Example comment
  10. */
  11. class Test extends CustomClass implements TestInterface
  12. {
  13. const C1 = null;
  14. // Magic constant: http://php.net/manual/ru/language.constants.predefined.php
  15. const className = __CLASS__;
  16. public function method1()
  17. {
  18. int a = 1, b = 2;
  19. return a + b;
  20. }
  21. // See fn is allowed like shortcut
  22. public fn method2() -> <Test>
  23. {
  24. call_user_func(function() { echo "hello"; });
  25. [1, 2, 3, 4, 5]->walk(
  26. function(int! x) {
  27. return x * x;
  28. }
  29. );
  30. [1, 2, 3, 4, 5]->walk(
  31. function(_, int key) { echo key; }
  32. );
  33. array input = [1, 2, 3, 4, 5];
  34. input->walk(
  35. function(_, int key) { echo key; }
  36. );
  37. input->map(x => x * x);
  38. return this;
  39. }
  40. }