005.phpt 913 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. --TEST--
  2. ReflectionMethod::getDocComment() uses wrong comment block
  3. --INI--
  4. opcache.save_comments=1
  5. opcache.load_comments=1
  6. --FILE--
  7. <?php
  8. function strip_doc_comment($c)
  9. {
  10. if (!strlen($c) || $c === false) return $c;
  11. return trim(substr($c, 3, -2));
  12. }
  13. /** Comment for class A */
  14. class A
  15. {
  16. /** Method A::bla()
  17. */
  18. function bla()
  19. {
  20. }
  21. function foo() {
  22. /**
  23. * This is a valid comment inside a method
  24. */
  25. }
  26. function bar() {
  27. // I don't have a doc comment....
  28. }
  29. /**
  30. * Comment for A::baz()
  31. */
  32. function baz() {
  33. }
  34. }
  35. $r = new ReflectionClass('A');
  36. var_dump(strip_doc_comment($r->getDocComment()));
  37. foreach($r->getMethods() as $m)
  38. {
  39. var_dump(strip_doc_comment($m->getDocComment()));
  40. }
  41. ?>
  42. ===DONE===
  43. --EXPECT--
  44. string(19) "Comment for class A"
  45. string(15) "Method A::bla()"
  46. bool(false)
  47. bool(false)
  48. string(22) "* Comment for A::baz()"
  49. ===DONE===