PageRenderTime 40ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/hphp/test/slow/traits/traits_and_interfaces7.php

http://github.com/facebook/hiphop-php
PHP | 41 lines | 32 code | 9 blank | 0 comment | 0 complexity | 007c815b49c2327b52abf93ec9aa6a08 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
  1. <?hh
  2. interface I {
  3. const XYZ = 'const from I';
  4. }
  5. interface J extends I {
  6. const ABC = 'const from J';
  7. }
  8. trait MyTrait implements J {}
  9. class C {
  10. use MyTrait;
  11. function f() {
  12. echo self::ABC, "\n";
  13. echo self::XYZ, "\n";
  14. }
  15. }
  16. function main() {
  17. $c = new C();
  18. $c->f();
  19. }
  20. function reflect() {
  21. echo '==========', ' ', __FUNCTION__, ' ', '==========', "\n";
  22. $rc = new ReflectionClass("C");
  23. print_r($rc->getInterfaceNames());
  24. print_r($rc->getConstants());
  25. print_r(get_class_constants((string)$rc));
  26. }
  27. <<__EntryPoint>>
  28. function main_traits_and_interfaces7() {
  29. error_reporting(-1);
  30. main();
  31. reflect();
  32. }