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

Bug #12651 Increment/Decrement Operators Usage at -1
Submitted: 2007-12-10 17:03 UTC
From: renoiv Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.0.0RC3)
PHP Version: 5.2.5 OS:
Roadmaps: 1.0.0    
Subscription  


 [2007-12-10 17:03 UTC] renoiv (renoiv)
Description: ------------ Squiz_Sniffs_Operators_IncrementDecrementUsageSniff. Addition -1 should become a decrement operator. Subtraction -1 should become an increment operator. I am not good at English. If a sentence of this bug is a unclear meaning, I am sorry. Test script: --------------- <?php $var += 1; $var -= 1; $var += -1; $var -= -1; ?> Expected result: ---------------- [test@]$ phpcs --standard=Squiz IncrementDecrementUsageTest.php FILE: IncrementDecrementUsageTest.php -------------------------------------------------------------------------------- 2 | ERROR | Missing file doc comment 2 | ERROR | Increment operators should be used where possible; found "$var += | | 1;" but expected "$var++" 3 | ERROR | Decrement operators should be used where possible; found "$var -= | | 1;" but expected "$var--" 4 | ERROR | Increment operators should be used where possible; found "$var += | | -1;" but expected "$var--" 5 | ERROR | Decrement operators should be used where possible; found "$var -= | | -1;" but expected "$var++" -------------------------------------------------------------------------------- Actual result: -------------- [test@]$ phpcs --standard=Squiz IncrementDecrementUsageTest.php FILE: IncrementDecrementUsageTest.php -------------------------------------------------------------------------------- 2 | ERROR | Missing file doc comment 2 | ERROR | Increment operators should be used where possible; found "$var += | | 1;" but expected "$var++" 3 | ERROR | Decrement operators should be used where possible; found "$var -= | | 1;" but expected "$var--" 4 | ERROR | Increment operators should be used where possible; found "$var += | | -1;" but expected "$var++" 5 | ERROR | Decrement operators should be used where possible; found "$var -= | | -1;" but expected "$var--"

Comments

 [2007-12-12 22:59 UTC] squiz (Greg Sherwood)
This bug has been fixed in CVS. 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.