note 107770 added to closure.bindto

From: Date: Sat, 03 Mar 2012 01:00:46 +0000
Subject: note 107770 added to closure.bindto
Groups: php.notes 
Request: Send a blank email to php-notes+get-186474@lists.php.net to get a copy of this message
Closures can rebind their $this variable, but private/protected methods and functions of $this are not accessible to the closures. <?php $fn = function(){ return $this->foo; }; class Bar{ private $foo = 3; } $bar = new Bar(); $fn = $fn->bindTo($bar); echo $fn(); // Fatal error: Cannot access private property Bar::$foo ---- Server IP: 69.147.83.197 Probable Submitter: 173.228.102.82 ---- Manual Page -- http://www.php.net/manual/en/closure.bindto.php Edit -- https://master.php.net/note/edit/107770 Del: integrated -- https://master.php.net/note/delete/107770/integrated Del: useless -- https://master.php.net/note/delete/107770/useless Del: bad code -- https://master.php.net/note/delete/107770/bad+code Del: spam -- https://master.php.net/note/delete/107770/spam Del: non-english -- https://master.php.net/note/delete/107770/non-english Del: in docs -- https://master.php.net/note/delete/107770/in+docs Del: other reasons-- https://master.php.net/note/delete/107770 Reject -- https://master.php.net/note/reject/107770 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#186474) next »