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