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

Bug #19759 Squiz.PHP.NonExecutableCode fails for return function()...
Submitted: 2012-12-21 01:00 UTC
From: edorian2 Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.4.3)
PHP Version: 5.3.20 OS: Linux
Roadmaps: (Not assigned)    
Subscription  


 [2012-12-21 01:00 UTC] edorian2 (Volker Dusch)
Description: ------------ When using the Squiz.PHP.NonExecutableCode sniff it fails to recognize that a function can be returned directly and treats the trailing ";" as non executable code. Regards and thank you so much for the time you spend on phpcs, Edorian Test script: --------------- ------ test.php ----- <?php function bar() { return function() { echo "1"; }; } $x = bar(); $x(); ---- SCRIPT ---- phpcs --standard=Squiz --sniffs=Squiz.PHP.NonExecutableCode test.php Expected result: ---------------- No errors Actual result: -------------- FILE: /.../test.php -------------------------------------------------------------------------------- FOUND 0 ERROR(S) AND 1 WARNING(S) AFFECTING 1 LINE(S) -------------------------------------------------------------------------------- 6 | WARNING | Code after RETURN statement cannot be executed --------------------------------------------------------------------------------

Comments

 [2013-01-07 04:38 UTC] squiz (Greg Sherwood)
-Assigned To: +Assigned To: squiz
Fix committed to github repo: https://github.com/squizlabs/PHP_CodeSniffer/commit/e439a1efb07c2abdb2163bbaca b0174ddb2f8a6b
 [2013-01-09 08:41 UTC] squiz (Greg Sherwood)
-Status: Assigned +Status: Closed