2014-10-09 31 views

回答

5

The docs say您只需將null作爲第一個參數invokeArgs即可執行靜態方法。

protected static function getMethod($name) { 
    $class = new ReflectionClass('MyClass'); 
    $method = $class->getMethod($name); 
    $method->setAccessible(true); 
    return $method; 
} 

public function testMakeMePublic() { 
    $foo = self::getMethod('makeMePublic'); 
    $foo->invokeArgs(null, $args); 
    ... 
} 
相關問題