Skip to content

Commit 3cb0587

Browse files
pepakrizkukulich
authored andcommitted
UselessParenthesesSniff: Fixed false positive
1 parent 742e60b commit 3cb0587

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

SlevomatCodingStandard/Sniffs/PHP/UselessParenthesesSniff.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,10 @@ private function checkParenthesesAroundOperators(File $phpcsFile, int $parenthes
461461
if ($tokens[$pointerBeforeParenthesisOpener]['code'] === T_DIVIDE && in_array($tokens[$firstOperatorPointer]['code'], [T_DIVIDE, T_MULTIPLY], true)) {
462462
return;
463463
}
464+
465+
if ($tokens[$pointerBeforeParenthesisOpener]['code'] === T_MODULUS && $tokens[$firstOperatorPointer]['code'] === T_MODULUS) {
466+
return;
467+
}
464468
}
465469

466470
$lastOperatorPointer = $operatorsPointers[count($operatorsPointers) - 1];

tests/Sniffs/PHP/data/uselessParenthesesNoErrors.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ function () {
133133

134134
$a = 10 - (5 - 2);
135135

136+
$a = 6 % (5 % 3);
137+
136138
pow(10, -($x + 1));
137139

138140
if (! ($i === $j - 1)) {

0 commit comments

Comments
 (0)