traits001.phpt 1013 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. --EXPECTF--
  19. bool(true)
  20. bool(false)
  21. Trait [ <user> trait Foo ] {
  22. @@ %straits001.php 2-4
  23. - Constants [0] {
  24. }
  25. - Static properties [0] {
  26. }
  27. - Static methods [0] {
  28. }
  29. - Properties [0] {
  30. }
  31. - Methods [1] {
  32. Method [ <user> public method someMethod ] {
  33. @@ %straits001.php 3 - 3
  34. }
  35. }
  36. }
  37. Class [ <user> class Bar ] {
  38. @@ %straits001.php 6-10
  39. - Constants [0] {
  40. }
  41. - Static properties [0] {
  42. }
  43. - Static methods [0] {
  44. }
  45. - Properties [0] {
  46. }
  47. - Methods [2] {
  48. Method [ <user> public method someOtherMethod ] {
  49. @@ %straits001.php 9 - 9
  50. }
  51. Method [ <user> public method someMethod ] {
  52. @@ %straits001.php 3 - 3
  53. }
  54. }
  55. }