ReflectionMethod_basic1.phpt 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. --TEST--
  2. ReflectionMethod class - various 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 "\nisFinal():\n";
  10. var_dump($methodInfo->isFinal());
  11. echo "\nisAbstract():\n";
  12. var_dump($methodInfo->isAbstract());
  13. echo "\nisPublic():\n";
  14. var_dump($methodInfo->isPublic());
  15. echo "\nisPrivate():\n";
  16. var_dump($methodInfo->isPrivate());
  17. echo "\nisProtected():\n";
  18. var_dump($methodInfo->isProtected());
  19. echo "\nisStatic():\n";
  20. var_dump($methodInfo->isStatic());
  21. echo "\nisConstructor():\n";
  22. var_dump($methodInfo->isConstructor());
  23. echo "\nisDestructor():\n";
  24. var_dump($methodInfo->isDestructor());
  25. echo "\n**********************************\n";
  26. }
  27. class TestClass
  28. {
  29. public function foo() {
  30. echo "Called foo()\n";
  31. }
  32. static function stat() {
  33. echo "Called stat()\n";
  34. }
  35. private function priv() {
  36. echo "Called priv()\n";
  37. }
  38. protected function prot() {}
  39. public function __destruct() {}
  40. }
  41. class DerivedClass extends TestClass {}
  42. interface TestInterface {
  43. public function int();
  44. public function __construct($arg);
  45. public function __destruct();
  46. }
  47. trait TestTrait {
  48. public abstract function __construct();
  49. public function __destruct() {
  50. }
  51. }
  52. reflectMethod("DerivedClass", "foo");
  53. reflectMethod("TestClass", "stat");
  54. reflectMethod("TestClass", "priv");
  55. reflectMethod("TestClass", "prot");
  56. reflectMethod("DerivedClass", "prot");
  57. reflectMethod("TestInterface", "int");
  58. reflectMethod("ReflectionProperty", "__construct");
  59. reflectMethod("TestClass", "__destruct");
  60. reflectMethod("TestInterface", "__construct");
  61. reflectMethod("TestInterface", "__destruct");
  62. reflectMethod("TestTrait", "__construct");
  63. reflectMethod("TestTrait", "__destruct");
  64. ?>
  65. --EXPECT--
  66. **********************************
  67. Reflecting on method DerivedClass::foo()
  68. isFinal():
  69. bool(false)
  70. isAbstract():
  71. bool(false)
  72. isPublic():
  73. bool(true)
  74. isPrivate():
  75. bool(false)
  76. isProtected():
  77. bool(false)
  78. isStatic():
  79. bool(false)
  80. isConstructor():
  81. bool(false)
  82. isDestructor():
  83. bool(false)
  84. **********************************
  85. **********************************
  86. Reflecting on method TestClass::stat()
  87. isFinal():
  88. bool(false)
  89. isAbstract():
  90. bool(false)
  91. isPublic():
  92. bool(true)
  93. isPrivate():
  94. bool(false)
  95. isProtected():
  96. bool(false)
  97. isStatic():
  98. bool(true)
  99. isConstructor():
  100. bool(false)
  101. isDestructor():
  102. bool(false)
  103. **********************************
  104. **********************************
  105. Reflecting on method TestClass::priv()
  106. isFinal():
  107. bool(false)
  108. isAbstract():
  109. bool(false)
  110. isPublic():
  111. bool(false)
  112. isPrivate():
  113. bool(true)
  114. isProtected():
  115. bool(false)
  116. isStatic():
  117. bool(false)
  118. isConstructor():
  119. bool(false)
  120. isDestructor():
  121. bool(false)
  122. **********************************
  123. **********************************
  124. Reflecting on method TestClass::prot()
  125. isFinal():
  126. bool(false)
  127. isAbstract():
  128. bool(false)
  129. isPublic():
  130. bool(false)
  131. isPrivate():
  132. bool(false)
  133. isProtected():
  134. bool(true)
  135. isStatic():
  136. bool(false)
  137. isConstructor():
  138. bool(false)
  139. isDestructor():
  140. bool(false)
  141. **********************************
  142. **********************************
  143. Reflecting on method DerivedClass::prot()
  144. isFinal():
  145. bool(false)
  146. isAbstract():
  147. bool(false)
  148. isPublic():
  149. bool(false)
  150. isPrivate():
  151. bool(false)
  152. isProtected():
  153. bool(true)
  154. isStatic():
  155. bool(false)
  156. isConstructor():
  157. bool(false)
  158. isDestructor():
  159. bool(false)
  160. **********************************
  161. **********************************
  162. Reflecting on method TestInterface::int()
  163. isFinal():
  164. bool(false)
  165. isAbstract():
  166. bool(true)
  167. isPublic():
  168. bool(true)
  169. isPrivate():
  170. bool(false)
  171. isProtected():
  172. bool(false)
  173. isStatic():
  174. bool(false)
  175. isConstructor():
  176. bool(false)
  177. isDestructor():
  178. bool(false)
  179. **********************************
  180. **********************************
  181. Reflecting on method ReflectionProperty::__construct()
  182. isFinal():
  183. bool(false)
  184. isAbstract():
  185. bool(false)
  186. isPublic():
  187. bool(true)
  188. isPrivate():
  189. bool(false)
  190. isProtected():
  191. bool(false)
  192. isStatic():
  193. bool(false)
  194. isConstructor():
  195. bool(true)
  196. isDestructor():
  197. bool(false)
  198. **********************************
  199. **********************************
  200. Reflecting on method TestClass::__destruct()
  201. isFinal():
  202. bool(false)
  203. isAbstract():
  204. bool(false)
  205. isPublic():
  206. bool(true)
  207. isPrivate():
  208. bool(false)
  209. isProtected():
  210. bool(false)
  211. isStatic():
  212. bool(false)
  213. isConstructor():
  214. bool(false)
  215. isDestructor():
  216. bool(true)
  217. **********************************
  218. **********************************
  219. Reflecting on method TestInterface::__construct()
  220. isFinal():
  221. bool(false)
  222. isAbstract():
  223. bool(true)
  224. isPublic():
  225. bool(true)
  226. isPrivate():
  227. bool(false)
  228. isProtected():
  229. bool(false)
  230. isStatic():
  231. bool(false)
  232. isConstructor():
  233. bool(true)
  234. isDestructor():
  235. bool(false)
  236. **********************************
  237. **********************************
  238. Reflecting on method TestInterface::__destruct()
  239. isFinal():
  240. bool(false)
  241. isAbstract():
  242. bool(true)
  243. isPublic():
  244. bool(true)
  245. isPrivate():
  246. bool(false)
  247. isProtected():
  248. bool(false)
  249. isStatic():
  250. bool(false)
  251. isConstructor():
  252. bool(false)
  253. isDestructor():
  254. bool(true)
  255. **********************************
  256. **********************************
  257. Reflecting on method TestTrait::__construct()
  258. isFinal():
  259. bool(false)
  260. isAbstract():
  261. bool(true)
  262. isPublic():
  263. bool(true)
  264. isPrivate():
  265. bool(false)
  266. isProtected():
  267. bool(false)
  268. isStatic():
  269. bool(false)
  270. isConstructor():
  271. bool(true)
  272. isDestructor():
  273. bool(false)
  274. **********************************
  275. **********************************
  276. Reflecting on method TestTrait::__destruct()
  277. isFinal():
  278. bool(false)
  279. isAbstract():
  280. bool(false)
  281. isPublic():
  282. bool(true)
  283. isPrivate():
  284. bool(false)
  285. isProtected():
  286. bool(false)
  287. isStatic():
  288. bool(false)
  289. isConstructor():
  290. bool(false)
  291. isDestructor():
  292. bool(true)
  293. **********************************