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

Bug #19685 PSR2 catch-22 with empty third statement in for loop
Submitted: 2012-10-31 03:19 UTC
From: wenslayer Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.4.0)
PHP Version: 5.3.18 OS: Irrelevant
Roadmaps: (Not assigned)    

 [2012-10-31 03:19 UTC] wenslayer (Marc Wensauer)
Description: ------------ With a for loop that has an empty third statement, PSR2 will complain that there is either no space following the semi-colon, or, once adding one, will complain that there is a space before the closing parenthesis. (Script below sniffed via 'phpcs --standard=PSR2') Test script: --------------- <?php for ($i=0; $j<3;) { print "i={$i}\n"; $i++ } for ($j=0; $j<3; ) { print "j={$j}\n"; $j++ } Expected result: ---------------- No errors Actual result: -------------- FOUND 2 ERROR(S) AFFECTING 2 LINE(S) --------------------------------------------------------------------------- ----- 2 | ERROR | Expected 1 space after second semicolon of FOR loop; 0 found 7 | ERROR | Space found before closing bracket of FOR loop


 [2012-10-31 07:14 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Closed -Assigned To: +Assigned To: squiz
Fixed in github repo: c8d069ddd67c0d5 Should be no space after the second semicolon if there is no third statement.