Edit report at http://pear.php.net/bugs/bug.php?id=16961&edit=1
ID: 16961
Updated by: [email protected]
Reported By: thezero at jyxo dot com
Summary: Add support for anonymous functions in PHP 5.3
Status: Open
Type: Feature/Change Request
Package: PHP_CodeSniffer
Package Version: CVS
PHP Version: 5.3.1
Roadmap Versions:
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2009-12-31 11:53:44] thezero
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);
});
}
}
------------------------------------------------------------------------