Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 3.7.2

Request #16961 Add support for anonymous functions in PHP 5.3
Submitted: 2009-12-31 16:53 UTC
From: thezero Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version CVS)
PHP Version: 5.3.1 OS:
Roadmaps: (Not assigned)    
Subscription  


 [2009-12-31 16:53 UTC] thezero (Jakub Tománek)
Description: ------------ Anonymous functions in PHP 5.3 now emit E_NOTICE in Generic_Sniffs_Formatting_DisallowMultipleStatementsSniff on lines 66 a 67. Also, they raise many false positives in following sniffs: * Squiz_Sniffs_PHP_InnerFunctionsSniff * Squiz_Sniffs_Scope_MethodScopeSniff * Generic_Sniffs_Functions_OpeningFunctionBraceBsdAllmanSniff (I believe anonymous functions should have bracket on the same line as function keyword) * Squiz_Sniffs_PHP_NonExecutableCodeSniff and possibly others. Test script: --------------- <?php class User_Data_Memcache implements User_Data_Source { public function getData(User_Interface $user) { $fallback = $this->fallback; return $this->find(self::CACHE_KEY_EXTENDED . $user->username(), function() use ($fallback, $user) { return $fallback->getData($user); }); } }

Comments

 [2010-01-11 02:58 UTC] squiz (Greg Sherwood)
PHP_CodeSniffer core has support for closures, but each sniff needs to check for them using the core functions. I've been fixing sniffs as I find them, so this task is ongoing.
 [2010-01-11 02:58 UTC] squiz (Greg Sherwood)
-Assigned To: +Assigned To: squiz
 [2010-08-11 10:32 UTC] squiz (Greg Sherwood)
-Status: Assigned +Status: Closed
Considering this is an ongoing feature request, I'm going to close it and just deal with any issues as bug reports.
 [2010-08-20 14:21 UTC] jeff_dickey (Jeff Dickey)
Would it be possible to link to such bug reports from this feature request or other easily-findable place? I'm currently working on a couple of projects that have been using the PEAR sniffs with the attitude "we shouldn't have to write our own code standards..."