Binding object instances to static closures

From: Date: Fri, 31 May 2013 17:54:14 +0000
Subject: Binding object instances to static closures
Groups: php.general 
Request: Send a blank email to php-general+get-321303@lists.php.net to get a copy of this message
Is it possible to bind an instance to a static closure, or to create a non-static closure inside of a static class method? This is what I mean... <?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();

« previous php.general (#321303) next »