traits001.phpt 1016 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. --TEST--
  2. ReflectionClass and Traits
  3. --FILE--
  4. <?php
  5. trait Foo {
  6. public function someMethod() { }
  7. }
  8. class Bar {
  9. use Foo;
  10. public function someOtherMethod() { }
  11. }
  12. $rFoo = new ReflectionClass('Foo');
  13. $rBar = new ReflectionClass('Bar');
  14. var_dump($rFoo->isTrait());
  15. var_dump($rBar->isTrait());
  16. echo $rFoo;
  17. echo $rBar;
  18. ?>
  19. --EXPECTF--
  20. bool(true)
  21. bool(false)
  22. Trait [ <user> trait Foo ] {
  23. @@ %straits001.php 2-4
  24. - Constants [0] {
  25. }
  26. - Static properties [0] {
  27. }
  28. - Static methods [0] {
  29. }
  30. - Properties [0] {
  31. }
  32. - Methods [1] {
  33. Method [ <user> public method someMethod ] {
  34. @@ %straits001.php 3 - 3
  35. }
  36. }
  37. }
  38. Class [ <user> class Bar ] {
  39. @@ %straits001.php 6-10
  40. - Constants [0] {
  41. }
  42. - Static properties [0] {
  43. }
  44. - Static methods [0] {
  45. }
  46. - Properties [0] {
  47. }
  48. - Methods [2] {
  49. Method [ <user> public method someOtherMethod ] {
  50. @@ %straits001.php 9 - 9
  51. }
  52. Method [ <user> public method someMethod ] {
  53. @@ %straits001.php 3 - 3
  54. }
  55. }
  56. }