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

Bug #16902 Inline If Declaration bug
Submitted: 2009-12-12 11:35 UTC
From: bpearson Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version Unknown)
PHP Version: 5.2.0 OS: N/A
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 : 16 + 26 = ?

 
 [2009-12-12 11:35 UTC] bpearson (Benjamin Pearson)
Description: ------------ In the inline if declaration (Standards/Squiz/Sniffs/ControlStructures/InlineIfDeclarationSniff.php) around line 64, the logic of the for loop looks like it goes: Start at end of tokens If parenthesis opener found in token set i to that and jump to i-1 (continue in the loop) If current i = open parenthesis token then get out of here. Loop til start reached Therefore if the close parenthesis is found it sets to i then jumps to the next i down, skipping over the test to get out of the loop. I tried removing the continue and it works on a simple inline if statement. Test script: --------------- <?php echo (TRUE)?'Hello':'Bye'; ?> Expected result: ---------------- if running through phpcs on a standard with this sniff enabled it should throw errors about missing spaces, currently it does not. Actual result: -------------- No errors thrown

Comments

 [2009-12-14 05:40 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. Funny thing is that the Squiz standard specifically bans inline IF statements, but I'll leave this sniff in there in case we decide to conditionally allow them.