Skip to content

Commit a0bf89e

Browse files
committed
SlevomatCodingStandard.PHP.UselessParentheses: Fixed false positive for bitwise not operator
1 parent 1501a61 commit a0bf89e

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

SlevomatCodingStandard/Sniffs/PHP/UselessParenthesesSniff.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use const T_ANON_CLASS;
1717
use const T_ARRAY_CAST;
1818
use const T_BITWISE_AND;
19+
use const T_BITWISE_NOT;
1920
use const T_BITWISE_OR;
2021
use const T_BITWISE_XOR;
2122
use const T_BOOL_CAST;
@@ -161,6 +162,7 @@ public function process(File $phpcsFile, $parenthesisOpenerPointer): void
161162
T_BOOL_CAST,
162163
T_UNSET_CAST,
163164
T_MATCH,
165+
T_BITWISE_NOT,
164166
],
165167
), true)
166168
) {

tests/Sniffs/PHP/data/uselessParenthesesNoErrors.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ function ($value) {
180180
$response = (new Response())->withStatus(200);
181181
$ip = (new RemoteAddress())?->getIpAddress();
182182

183+
echo ~(1 - 1);
184+
183185
// Must be last
184186
return true
185187
? 100

0 commit comments

Comments
 (0)