Skip to content

Commit

Permalink
UselessParenthesesSniff: Fixed false positive
Browse files Browse the repository at this point in the history
  • Loading branch information
pepakriz authored and kukulich committed Dec 13, 2019
1 parent 742e60b commit 3cb0587
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions SlevomatCodingStandard/Sniffs/PHP/UselessParenthesesSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,10 @@ private function checkParenthesesAroundOperators(File $phpcsFile, int $parenthes
if ($tokens[$pointerBeforeParenthesisOpener]['code'] === T_DIVIDE && in_array($tokens[$firstOperatorPointer]['code'], [T_DIVIDE, T_MULTIPLY], true)) {
return;
}

if ($tokens[$pointerBeforeParenthesisOpener]['code'] === T_MODULUS && $tokens[$firstOperatorPointer]['code'] === T_MODULUS) {
return;
}
}

$lastOperatorPointer = $operatorsPointers[count($operatorsPointers) - 1];
Expand Down
2 changes: 2 additions & 0 deletions tests/Sniffs/PHP/data/uselessParenthesesNoErrors.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ function () {

$a = 10 - (5 - 2);

$a = 6 % (5 % 3);

pow(10, -($x + 1));

if (! ($i === $j - 1)) {
Expand Down

0 comments on commit 3cb0587

Please sign in to comment.