Skip to content

Commit 8aa456f

Browse files
committed
SlevomatCodingStandard.PHPUselessParentheses: Fixed false positive
1 parent 3284f1f commit 8aa456f

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
@@ -232,6 +232,10 @@ private function checkParenthesesAroundConditionInTernaryOperator(File $phpcsFil
232232
return;
233233
}
234234

235+
if (in_array($tokens[$pointerBeforeParenthesisOpener]['code'], self::OPERATORS, true)) {
236+
return;
237+
}
238+
235239
if (in_array($tokens[$pointerBeforeParenthesisOpener]['code'], Tokens::$comparisonTokens, true)) {
236240
return;
237241
}

tests/Sniffs/PHP/data/uselessParenthesesNoErrors.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ function ($value) {
177177

178178
$anotherObject = new ($object->getClassName());
179179

180+
echo 'Hello' . ($foo) ? ' There' : $fn();
181+
180182
// Must be last
181183
return true
182184
? 100

0 commit comments

Comments
 (0)