ReflectionFunction_001.phpt 985 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. --TEST--
  2. ReflectionFunction methods
  3. --CREDITS--
  4. Robin Fernandes <robinf@php.net>
  5. Steve Seear <stevseea@php.net>
  6. --FILE--
  7. <?php
  8. /**
  9. * my doc comment
  10. */
  11. function foo () {
  12. static $c;
  13. static $a = 1;
  14. static $b = "hello";
  15. $d = 5;
  16. }
  17. /***
  18. * not a doc comment
  19. */
  20. function bar () {}
  21. function dumpFuncInfo($name) {
  22. $funcInfo = new ReflectionFunction($name);
  23. var_dump($funcInfo->getName());
  24. var_dump($funcInfo->isInternal());
  25. var_dump($funcInfo->isUserDefined());
  26. var_dump($funcInfo->getStartLine());
  27. var_dump($funcInfo->getEndLine());
  28. var_dump($funcInfo->getStaticVariables());
  29. }
  30. dumpFuncInfo('foo');
  31. dumpFuncInfo('bar');
  32. dumpFuncInfo('extract');
  33. ?>
  34. --EXPECT--
  35. string(3) "foo"
  36. bool(false)
  37. bool(true)
  38. int(6)
  39. int(11)
  40. array(3) {
  41. ["c"]=>
  42. NULL
  43. ["a"]=>
  44. int(1)
  45. ["b"]=>
  46. string(5) "hello"
  47. }
  48. string(3) "bar"
  49. bool(false)
  50. bool(true)
  51. int(16)
  52. int(16)
  53. array(0) {
  54. }
  55. string(7) "extract"
  56. bool(true)
  57. bool(false)
  58. bool(false)
  59. bool(false)
  60. array(0) {
  61. }