Skip to content

Commit 66a8e26

Browse files
committed
UselessParenthesesSniff: Fixed false positive
1 parent 9978172 commit 66a8e26

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

SlevomatCodingStandard/Sniffs/PHP/UselessParenthesesSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,12 @@ private function containsOperators(File $phpcsFile, int $parenthesisOpenerPointe
106106
}
107107

108108
$pointerAfterParenthesis = TokenHelper::findNextEffective($phpcsFile, $tokens[$parenthesisOpenerPointer]['parenthesis_closer'] + 1);
109-
if (in_array($tokens[$pointerAfterParenthesis]['code'], [T_MULTIPLY, T_DIVIDE], true)) {
109+
if (in_array($tokens[$pointerAfterParenthesis]['code'], [T_MULTIPLY, T_DIVIDE, T_STRING_CONCAT], true)) {
110110
return true;
111111
}
112112

113113
$pointerBeforeParenthesis = TokenHelper::findPreviousEffective($phpcsFile, $parenthesisOpenerPointer - 1);
114-
if (in_array($tokens[$pointerBeforeParenthesis]['code'], [T_MULTIPLY, T_DIVIDE], true)) {
114+
if (in_array($tokens[$pointerBeforeParenthesis]['code'], [T_MULTIPLY, T_DIVIDE, T_STRING_CONCAT], true)) {
115115
return true;
116116
}
117117

tests/Sniffs/PHP/data/uselessParenthesesNoErrors.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,5 @@ function () {
9191
$a = ('100' . '000') * $c;
9292

9393
$a = $b + (100 - $c);
94+
95+
$a = 'a' . '/' . (32 - ($b * 8));

0 commit comments

Comments
 (0)