是否可以将实例绑定到静态闭包,或者在静态类方法中创建非静态闭包?
这就是我的意思...
<?php
class TestClass {
public static function testMethod() {
$testInstance = new TestClass();
$testClosure = function() use ($testInstance) {
return $this === $testInstance;
};
$bindedTestClosure = $testClosure->bindTo($testInstance);
call_user_func($bindedTestClosure);
// should be true
}
}
TestClass::testMethod();