Edit report at http://bugs.php.net/bug.php?id=53610&edit=1
ID: 53610 Comment by: ivan1986 at list dot ru Reported by: sergey dot s dot betke at novgaro dot ru Summary: closure and static private class member Status: Open Type: Feature/Change Request Package: Class/Object related Operating System: Windows PHP Version: 5.3.4 Block user comment: N Private report: N New Comment: class Filter { public function filter($value = '') { return function() use ($value) { return $value; }; } } class Test { private $_filter = null; public function test() { $filter = new Filter(); $this->_filter = $filter->filter(); echo 'filter data: ' . $this->_filter('my data'); //error $f = $this->_filter; echo 'filter data: ' . $f('my data'); //work } } $T= new Test(); $T->test(); http://www.askdev.ru/php/5450/ÐамÑканиÑ/ Previous Comments: ------------------------------------------------------------------------ [2010-12-26 00:28:19] sergey dot s dot betke at novgaro dot ru My article in Russian on this issue <a href="http://sergey-s-betke.blogs.novgaro.ru/lyambda-funkcii-zamykaniya-i-klassy-php">http://sergey-s-betke.blogs.novgaro.ru/lyambda-funkcii-zamykaniya-i-klassy-php</a>. ------------------------------------------------------------------------ [2010-12-26 00:19:09] sergey dot s dot betke at novgaro dot ru Description: ------------ just one example: class test { private static $_domain; static member() { add_settings_section( self::$_namespace . '_location_options', __('Location of your opensearch.xml file', self::$_domain), function () { ?> <p><?php _e('You can select location of your opensearch.xml file and his url, or leave automatic detection.', self::$_domain); ?></p> <?php }, self::$_namespace . '_options_page' ); } } and, this sample - not working. I honestly do not understand, and therefore the PHP developers do not consider the closure, created by the code of methods of class, as a class method. But it is implicitly "import" $this. Test script: --------------- class test { private static $_domain; static test_member() { add_settings_section( // wordpress API self::$_namespace . '_location_options', __('Location of your opensearch.xml file', self::$_domain), function () { ?> <p><?php _e('You can select location of your opensearch.xml file and his url, or leave automatic detection.', self::$_domain); ?></p> <?php }, self::$_namespace . '_options_page' ); } } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=53610&edit=1