005.phpt 891 B

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