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

Bug #18073 Squiz.PHP.NonExecutableCode fault
Submitted: 2010-11-18 22:33 UTC
From: glen Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.3.0RC1)
PHP Version: 5.3.3 OS:
Roadmaps: (Not assigned)    
Subscription  


 [2010-11-18 22:33 UTC] glen (Elan Ruusamäe)
Description: ------------ Squiz.PHP.NonExecutableCode reports dead code, even it is not. the thing is that in PHP functions are declared at file compile time not run time.(test1.php, test2.php) yet you can omit definition the function in conditionals (test3.php) - - go figure! Test script: --------------- $ phpcs --standard=phpcs.xml . -v Registering sniffs in standard... DONE (1 sniffs registered) Processing test3.php [46 tokens in 10 lines]... DONE in < 1 second (0 errors, 5 warnings) Processing test2.php [34 tokens in 8 lines]... DONE in < 1 second (0 errors, 3 warnings) Processing test1.php [34 tokens in 8 lines]... DONE in < 1 second (0 errors, 3 warnings) FILE: /home/glen/bzr/eventum/phpcs/exec-branch/test1.php -------------------------------------------------------------------------------- FOUND 0 ERROR(S) AFFECTING 3 LINE(S) -------------------------------------------------------------------------------- 6 | WARNING | Code after EXIT statement cannot be executed 7 | WARNING | Code after EXIT statement cannot be executed 8 | WARNING | Code after EXIT statement cannot be executed -------------------------------------------------------------------------------- FILE: /home/glen/bzr/eventum/phpcs/exec-branch/test2.php -------------------------------------------------------------------------------- FOUND 0 ERROR(S) AFFECTING 3 LINE(S) -------------------------------------------------------------------------------- 6 | WARNING | Code after RETURN statement cannot be executed 7 | WARNING | Code after RETURN statement cannot be executed 8 | WARNING | Code after RETURN statement cannot be executed -------------------------------------------------------------------------------- FILE: /home/glen/bzr/eventum/phpcs/exec-branch/test3.php -------------------------------------------------------------------------------- FOUND 0 ERROR(S) AFFECTING 5 LINE(S) -------------------------------------------------------------------------------- 6 | WARNING | Code after EXIT statement cannot be executed 7 | WARNING | Code after EXIT statement cannot be executed 8 | WARNING | Code after EXIT statement cannot be executed 9 | WARNING | Code after EXIT statement cannot be executed 10 | WARNING | Code after EXIT statement cannot be executed -------------------------------------------------------------------------------- Actual result: -------------- $ php test1.php 4 $ php test2.php 4 $ php test3.php PHP Fatal error: Call to undefined function testfunc() in /home/glen/bzr/eventum/phpcs/exec-branch/test3.php on line 3 PHP Stack trace: PHP 1. {main}() /home/glen/bzr/eventum/phpcs/exec- branch/test3.php:0

Comments

 [2010-11-18 22:35 UTC] glen (Elan Ruusamäe)
 [2010-11-18 22:37 UTC] glen (Elan Ruusamäe)
 [2010-11-18 22:38 UTC] glen (Elan Ruusamäe)
 [2010-11-18 22:38 UTC] glen (Elan Ruusamäe)
 [2010-11-18 22:39 UTC] glen (Elan Ruusamäe)
(stupid bug tracker, first it asked if i want to attach files, and if i checked yes, it accepted only "patches" not just "files")
 [2010-11-19 08:53 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Closed -Assigned To: +Assigned To: squiz
This bug has been fixed in SVN. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.