ReflectionMethod_getDocComment_basic.phpt 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. --TEST--
  2. ReflectionMethod::getDocComment()
  3. --INI--
  4. opcache.save_comments=1
  5. opcache.load_comments=1
  6. --FILE--
  7. <?php
  8. /**
  9. * My Doc Comment for A
  10. */
  11. class A {
  12. /**
  13. * My Doc Comment for A::f
  14. */
  15. function f() {}
  16. /**
  17. * My Doc Comment for A::privf
  18. */
  19. private function privf() {}
  20. /** My Doc Comment for A::protStatf */
  21. protected static function protStatf() {}
  22. /**
  23. * My Doc Comment for A::finalStatPubf
  24. */
  25. final static public function finalStatPubf() {}
  26. }
  27. class B extends A {
  28. /*** Not a doc comment */
  29. function f() {}
  30. /** *
  31. * My Doc Comment for B::privf
  32. */
  33. private function privf() {}
  34. /** My Doc Comment for B::protStatf
  35. */
  36. protected static function protStatf() {}
  37. }
  38. foreach (array('A', 'B') as $class) {
  39. $rc = new ReflectionClass($class);
  40. $rms = $rc->getMethods();
  41. foreach ($rms as $rm) {
  42. echo "\n\n---> Doc comment for $class::" . $rm->getName() . "():\n";
  43. var_dump($rm->getDocComment());
  44. }
  45. }
  46. ?>
  47. --EXPECTF--
  48. ---> Doc comment for A::f():
  49. string(%d) "/**
  50. * My Doc Comment for A::f
  51. */"
  52. ---> Doc comment for A::privf():
  53. string(%d) "/**
  54. * My Doc Comment for A::privf
  55. */"
  56. ---> Doc comment for A::protStatf():
  57. string(%d) "/** My Doc Comment for A::protStatf */"
  58. ---> Doc comment for A::finalStatPubf():
  59. string(%d) "/**
  60. * My Doc Comment for A::finalStatPubf
  61. */"
  62. ---> Doc comment for B::f():
  63. bool(false)
  64. ---> Doc comment for B::privf():
  65. string(%d) "/** *
  66. * My Doc Comment for B::privf
  67. */"
  68. ---> Doc comment for B::protStatf():
  69. string(%d) "/** My Doc Comment for B::protStatf
  70. */"
  71. ---> Doc comment for B::finalStatPubf():
  72. string(%d) "/**
  73. * My Doc Comment for A::finalStatPubf
  74. */"