ReflectionClass_hasMethod_basic.phpt 1010 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. --TEST--
  2. ReflectionClass::hasMethod()
  3. --CREDITS--
  4. Marc Veldman <marc@ibuildings.nl>
  5. #testfest roosendaal on 2008-05-10
  6. --FILE--
  7. <?php
  8. //New instance of class C - defined below
  9. $rc = new ReflectionClass("C");
  10. //Check if C has public method publicFoo
  11. var_dump($rc->hasMethod('publicFoo'));
  12. //Check if C has protected method protectedFoo
  13. var_dump($rc->hasMethod('protectedFoo'));
  14. //Check if C has private method privateFoo
  15. var_dump($rc->hasMethod('privateFoo'));
  16. //Check if C has static method staticFoo
  17. var_dump($rc->hasMethod('staticFoo'));
  18. //C should not have method bar
  19. var_dump($rc->hasMethod('bar'));
  20. //Method names are case insensitive
  21. var_dump($rc->hasMethod('PUBLICfOO'));
  22. Class C {
  23. public function publicFoo()
  24. {
  25. return true;
  26. }
  27. protected function protectedFoo()
  28. {
  29. return true;
  30. }
  31. private function privateFoo()
  32. {
  33. return true;
  34. }
  35. static function staticFoo()
  36. {
  37. return true;
  38. }
  39. }
  40. ?>
  41. --EXPECT--
  42. bool(true)
  43. bool(true)
  44. bool(true)
  45. bool(true)
  46. bool(false)
  47. bool(true)