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

Bug #20123 PSR2 complains about an empty second statement in for-loop.
Submitted: 2013-11-07 09:08 UTC
From: repeat Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.4.7)
PHP Version: 5.4.21 OS: FreeBSD
Roadmaps: (Not assigned)    
Subscription  


 [2013-11-07 09:08 UTC] repeat (Repeat Yang)
Description: ------------ Prepare a for-loop with an empty second statement. PSR complains there is no space after the first semicolon if I did not put one, and complains there is one space before the second semicolon if I put one. The situation is similar to bug #19685. Test script: --------------- <?php for ($i = 0;; $i++) { if ($i > 5) { break; } } for ($i = 0; ; $i++) { if ($i > 5) { break; } } Expected result: ---------------- 1 error, so I can fix another. Actual result: -------------- ------------------------------------------------------------------------ -------- FOUND 2 ERROR(S) AFFECTING 2 LINE(S) ------------------------------------------------------------------------ -------- 2 | ERROR | Expected 1 space after first semicolon of FOR loop; 0 found 8 | ERROR | Space found before second semicolon of FOR loop ------------------------------------------------------------------------ --------

Comments

 [2013-11-15 06:11 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Closed -Assigned To: +Assigned To: squiz
Fix committed to github repo: https://github.com/squizlabs/PHP_CodeSniffer/commit/69389641c04f0534abf75890fe9 d184bf1c0ae92 If will require the following syntax (no space): for ($i = 0;; $i++) { ...