ReflectionMethod_getStaticVariables_basic.phpt 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. --TEST--
  2. ReflectionMethod::getStaticVariables()
  3. --FILE--
  4. <?php
  5. class TestClass {
  6. public function foo() {
  7. static $c;
  8. static $a = 1;
  9. static $b = "hello";
  10. $d = 5;
  11. }
  12. private function bar() {
  13. static $a = 1;
  14. }
  15. public function noStatics() {
  16. $a = 54;
  17. }
  18. }
  19. echo "Public method:\n";
  20. $methodInfo = new ReflectionMethod('TestClass::foo');
  21. var_dump($methodInfo->getStaticVariables());
  22. echo "\nPrivate method:\n";
  23. $methodInfo = new ReflectionMethod('TestClass::bar');
  24. var_dump($methodInfo->getStaticVariables());
  25. echo "\nMethod with no static variables:\n";
  26. $methodInfo = new ReflectionMethod('TestClass::noStatics');
  27. var_dump($methodInfo->getStaticVariables());
  28. echo "\nInternal Method:\n";
  29. $methodInfo = new ReflectionMethod('ReflectionClass::getName');
  30. var_dump($methodInfo->getStaticVariables());
  31. ?>
  32. --EXPECT--
  33. Public method:
  34. array(3) {
  35. ["c"]=>
  36. NULL
  37. ["a"]=>
  38. int(1)
  39. ["b"]=>
  40. string(5) "hello"
  41. }
  42. Private method:
  43. array(1) {
  44. ["a"]=>
  45. int(1)
  46. }
  47. Method with no static variables:
  48. array(0) {
  49. }
  50. Internal Method:
  51. array(0) {
  52. }