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

Bug #19463 Anonymous functions incorrectly being flagged by NonExecutableCodeSniff
Submitted: 2012-06-08 00:19 UTC
From: qbert00001 Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version SVN)
PHP Version: 5.3.10 OS:
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 43 + 36 = ?

 
 [2012-06-08 00:19 UTC] qbert00001 (greg horvath)
Description: ------------ Still seeing erroneous flagging of code as being unreachable by the NonExecutableCodeSniff. The method provided in the ticket causes a sniff failure, though it is valid code (and contains no unreachable code). Currently running PHPCS v1.3.3 Haven't upgraded yet as I don't see any tickets or release notes indicating that this problem has been fixed in a subsequent release, and was not able to locate any similar currently open bugs. Test script: --------------- public static function thisCausesAnError() { return new foo('bar', array('baz'), function(type1 $x, type2 $y) { return $x->foo2($y->data, $y->foo3('blah')); } ); } Expected result: ---------------- No errors reported. Actual result: -------------- (Snip from checkstyle output): <file name="/home/user/workspace/src/My/Class.php"> <error line="88" column="10" severity="warning" message="Code after RETURN statement cannot be executed" source="Squiz.PHP.NonExecutableCode.Unreachable"/> </file>

Comments

 [2012-06-19 12:56 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Closed -Assigned To: +Assigned To: squiz
Closures are normally skipped, but this was a particular problem where the closure had a return statement in it as well. Fix committed to Github repo: https://github.com/squizlabs/PHP_CodeSniffer/commit/922eb0151285e2a97c80fe745 710e4f3b6779305
 [2012-06-20 00:41 UTC] qbert00001 (greg horvath)
Thanks for the quick fix. Will this be included in 1.3.5 and, if so, what is the current release timeline?
 [2012-06-20 04:10 UTC] squiz (Greg Sherwood)
Yes, it will be in 1.3.5. I don't know when it will be released, but you can install from a Git clone in the meantime if you want. Just clone the repo, then: pear uninstall php_codesniffer pear install package.xml When 1.3.5 comes out, you can grab it from PEAR again: pear uninstall php_codesniffer pear install php_codesniffer Or you can keep getting updates from the git repo if you want.