Skip to content

Commit e905dcf

Browse files
committed
UselessParenthesesSniff: Fixed false positives
1 parent 7864bf3 commit e905dcf

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

SlevomatCodingStandard/Sniffs/PHP/UselessParenthesesSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function process(File $phpcsFile, $parenthesisOpenerPointer): void
5555

5656
/** @var int $pointerBeforeParenthesisOpener */
5757
$pointerBeforeParenthesisOpener = TokenHelper::findPreviousEffective($phpcsFile, $parenthesisOpenerPointer - 1);
58-
if (in_array($tokens[$pointerBeforeParenthesisOpener]['code'], [T_VARIABLE, T_STRING, T_ISSET, T_UNSET, T_EMPTY, T_CLOSURE, T_USE, T_ANON_CLASS, T_SELF, T_STATIC], true)) {
58+
if (in_array($tokens[$pointerBeforeParenthesisOpener]['code'], [T_VARIABLE, T_STRING, T_ISSET, T_UNSET, T_EMPTY, T_CLOSURE, T_USE, T_ANON_CLASS, T_SELF, T_STATIC, T_EXIT], true)) {
5959
return;
6060
}
6161

tests/Sniffs/PHP/data/uselessParenthesesNoErrors.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,6 @@ function doSomething($parameter) {
4747

4848
$z = ($a ? '0' : '1') ? '2' : '3';
4949
$zz = ($a + $b);
50+
51+
exit($a);
52+
die($a);

0 commit comments

Comments
 (0)