我想從同一個類的其他方法內的閉包內調用一個類的私有靜態方法,我找不到正確的方法要做到這一點... 甚至使用使用引用私有方法...我能夠引用私有變量並傳遞它,但沒有辦法引用私有方法... $ refMethod = array('App 」, '_的onEvent');與使用call_user_func($ refMethod)將拋出的方法是私人的... 我試着用ReflectionClass與PHP 5.4版本也(WAMP 32位),但它說getClosure方法不存在的實例:(從閉包(類內)調用私有靜態方法
class App(){
static public function start(){
new Form('myform', array('submit'=>function($form) use($someVar){
if($anyCondition){
// want to call private self::_onEvent here : any suggestion ?
}
}));
}
static private function _onEvent(){
// this is my very private part
}
}
嗯,我知道相當封閉沒有範圍,但這樣...任何方式來傳遞專用上下文(因爲閉包是類中),用於完成這樣的感謝任何燈光
編輯?!我確實想要this answer但這只是拋出偉大的
無法訪問自己::當無級範圍活躍