Skip to content

Commit bb8be43

Browse files
committed
UselessParenthesesSniff: Fixed false positive
1 parent beea16e commit bb8be43

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
@@ -457,6 +457,10 @@ private function checkParenthesesAroundOperators(File $phpcsFile, int $parenthes
457457
if ($tokens[$pointerBeforeParenthesisOpener]['code'] === T_MINUS && $tokens[$firstOperatorPointer]['code'] === T_PLUS) {
458458
return;
459459
}
460+
461+
if ($tokens[$pointerBeforeParenthesisOpener]['code'] === T_DIVIDE && $tokens[$firstOperatorPointer]['code'] === T_DIVIDE) {
462+
return;
463+
}
460464
}
461465

462466
$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
@@ -127,6 +127,8 @@ function () {
127127

128128
$a = 10 + 1 - (5 + 4);
129129

130+
$a = 10 / (5 / 2);
131+
130132
pow(10, -($x + 1));
131133

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

0 commit comments

Comments
 (0)