ReflectionMethod_getDocComment_basic.phpt 1.7 KB

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