cvs: pear /PHP_CodeSniffer package.xml /PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Operators IncrementDecrementUsageSniff.php
/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Operators IncrementDecrementUsageUnitTest.inc
| From: | Greg Sherwood | Date: | Tue, 05 May 2009 06:28:10 +0000 |
| Subject: | cvs: pear /PHP_CodeSniffer package.xml /PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Operators IncrementDecrementUsageSniff.php /PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Operators IncrementDecrementUsageUnitTest.inc |
||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-56036@lists.php.net to get a copy of this message | ||
squiz Tue May 5 06:28:10 2009 UTC
Modified files:
/pear/PHP_CodeSniffer package.xml
/pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Operators
IncrementDecrementUsageSniff.php
/pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Operators
IncrementDecrementUsageUnitTest.inc
Log:
Fixed bug #16175 : Bug in Squiz-IncrementDecrementUsageSniff
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/package.xml?r1=1.396&r2=1.397&diff_format=u
Index: pear/PHP_CodeSniffer/package.xml
diff -u pear/PHP_CodeSniffer/package.xml:1.396 pear/PHP_CodeSniffer/package.xml:1.397
--- pear/PHP_CodeSniffer/package.xml:1.396 Tue May 5 06:08:54 2009
+++ pear/PHP_CodeSniffer/package.xml Tue May 5 06:28:09 2009
@@ -37,6 +37,7 @@
- Fixed bug #16001 : Notice triggered
- Fixed bug #16054 : phpcs-svn-pre-commit not showing any errors
- Fixed bug #16170 : Undefined Offset -1 in MultiLineConditionSniff.php on line 68
+ - Fixed bug #16175 : Bug in Squiz-IncrementDecrementUsageSniff
</notes>
<contents>
<dir name="/">
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php?r1=1.6&r2=1.7&diff_format=u
Index:
pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php
diff -u
pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php:1.6
pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php:1.7
---
pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php:1.6 Thu
Feb 28 22:40:50 2008
+++
pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php Tue
May 5 06:28:09 2009
@@ -10,7 +10,7 @@
* @author Marc McIntyre <mmcintyre@squiz.net>
* @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
* @license http://matrix.squiz.net/developer/tools/php_cs/licence
BSD Licence
- * @version CVS: $Id: IncrementDecrementUsageSniff.php,v 1.6 2008/02/28 22:40:50 squiz Exp $
+ * @version CVS: $Id: IncrementDecrementUsageSniff.php,v 1.7 2009/05/05 06:28:09 squiz Exp $
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
@@ -192,7 +192,15 @@
$nextNumber = $previousNumber;
if ($tokens[$nextNumber]['content'] === '1') {
if ($tokens[$stackPtr]['code'] === T_EQUAL) {
- $operator = $tokens[$phpcsFile->findNext(array(T_PLUS, T_MINUS), ($stackPtr +
1), $statementEnd)]['content'];
+ $opToken = $phpcsFile->findNext(array(T_PLUS, T_MINUS), ($nextVar + 1),
$statementEnd);
+ if ($opToken === false) {
+ // Operator was before the varaible, like:
+ // $var = 1 + $var;
+ // So we ignore it.
+ return;
+ }
+
+ $operator = $tokens[$opToken]['content'];
} else {
$operator = substr($tokens[$stackPtr]['content'], 0, 1);
}
@@ -217,7 +225,7 @@
$error .= " operators should be used where possible; found \"$found\"
but expected \"$expected\"";
$phpcsFile->addError($error, $stackPtr);
- }
+ }//end if
}//end processAssignment()
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc?r1=1.3&r2=1.4&diff_format=u
Index:
pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc
diff -u
pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc:1.3
pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc:1.4
---
pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc:1.3 Thu
Feb 28 22:40:50 2008
+++
pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc Tue
May 5 06:28:10 2009
@@ -30,4 +30,7 @@
$id = $id.'_'.($i++);
$id = $id.'_'.$i--.'_';
$id = $id.'_'.($i--).'_';
+
+$var = (1 - $var);
+$var = (1 + $var);
?>