ReflectionMethod_basic4.phpt 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. --TEST--
  2. ReflectionMethod class getFileName(), getStartLine() and getEndLine() methods
  3. --FILE--
  4. <?php
  5. function reflectMethod($class, $method) {
  6. $methodInfo = new ReflectionMethod($class, $method);
  7. echo "**********************************\n";
  8. echo "Reflecting on method $class::$method()\n\n";
  9. echo "\ngetFileName():\n";
  10. var_dump($methodInfo->getFileName());
  11. echo "\ngetStartLine():\n";
  12. var_dump($methodInfo->getStartLine());
  13. echo "\ngetEndLine():\n";
  14. var_dump($methodInfo->getEndLine());
  15. echo "\n**********************************\n";
  16. }
  17. class TestClass
  18. {
  19. public function foo() {
  20. echo "Called foo()\n";
  21. }
  22. static function stat() {
  23. echo "Called stat()\n";
  24. }
  25. private function priv() {
  26. echo "Called priv()\n";
  27. }
  28. protected function prot() {}
  29. public function __destruct() {}
  30. }
  31. class DerivedClass extends TestClass {}
  32. interface TestInterface {
  33. public function int();
  34. }
  35. reflectMethod("DerivedClass", "foo");
  36. reflectMethod("TestClass", "stat");
  37. reflectMethod("TestClass", "priv");
  38. reflectMethod("TestClass", "prot");
  39. reflectMethod("DerivedClass", "prot");
  40. reflectMethod("TestInterface", "int");
  41. reflectMethod("ReflectionProperty", "__construct");
  42. reflectMethod("TestClass", "__destruct");
  43. ?>
  44. --EXPECTF--
  45. **********************************
  46. Reflecting on method DerivedClass::foo()
  47. getFileName():
  48. string(%d) "%sReflectionMethod_basic4.php"
  49. getStartLine():
  50. int(18)
  51. getEndLine():
  52. int(24)
  53. **********************************
  54. **********************************
  55. Reflecting on method TestClass::stat()
  56. getFileName():
  57. string(%d) "%sReflectionMethod_basic4.php"
  58. getStartLine():
  59. int(26)
  60. getEndLine():
  61. int(28)
  62. **********************************
  63. **********************************
  64. Reflecting on method TestClass::priv()
  65. getFileName():
  66. string(%d) "%sReflectionMethod_basic4.php"
  67. getStartLine():
  68. int(30)
  69. getEndLine():
  70. int(32)
  71. **********************************
  72. **********************************
  73. Reflecting on method TestClass::prot()
  74. getFileName():
  75. string(%d) "%sReflectionMethod_basic4.php"
  76. getStartLine():
  77. int(34)
  78. getEndLine():
  79. int(34)
  80. **********************************
  81. **********************************
  82. Reflecting on method DerivedClass::prot()
  83. getFileName():
  84. string(%d) "%sReflectionMethod_basic4.php"
  85. getStartLine():
  86. int(34)
  87. getEndLine():
  88. int(34)
  89. **********************************
  90. **********************************
  91. Reflecting on method TestInterface::int()
  92. getFileName():
  93. string(%d) "%sReflectionMethod_basic4.php"
  94. getStartLine():
  95. int(42)
  96. getEndLine():
  97. int(42)
  98. **********************************
  99. **********************************
  100. Reflecting on method ReflectionProperty::__construct()
  101. getFileName():
  102. bool(false)
  103. getStartLine():
  104. bool(false)
  105. getEndLine():
  106. bool(false)
  107. **********************************
  108. **********************************
  109. Reflecting on method TestClass::__destruct()
  110. getFileName():
  111. string(%d) "%sReflectionMethod_basic4.php"
  112. getStartLine():
  113. int(36)
  114. getEndLine():
  115. int(36)
  116. **********************************