You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.1 KiB

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