Skip to content

Commit 057f3f1

Browse files
committed
UselessParenthesesSniff: Fixed internal error
1 parent 06d996b commit 057f3f1

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

SlevomatCodingStandard/Sniffs/PHP/UselessParenthesesSniff.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ private function checkParenthesesAroundVariableOrFunctionCall(File $phpcsFile, i
269269

270270
do {
271271
$nextPointer = TokenHelper::findNextEffective($phpcsFile, $contentEndPointer + 1);
272-
273272
if ($tokens[$nextPointer]['code'] !== T_OPEN_PARENTHESIS) {
274273
break;
275274
}
@@ -278,6 +277,10 @@ private function checkParenthesesAroundVariableOrFunctionCall(File $phpcsFile, i
278277
} while (true);
279278
} else {
280279
$nextPointer = TokenHelper::findNext($phpcsFile, T_OPEN_PARENTHESIS, $notBooleanNotOperatorPointer + 1);
280+
if ($nextPointer === null) {
281+
return;
282+
}
283+
281284
$contentEndPointer = $tokens[$nextPointer]['parenthesis_closer'];
282285
}
283286

tests/Sniffs/PHP/data/uselessParenthesesNoErrors.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,7 @@ function () {
100100
include_once($file);
101101
require($file);
102102
require_once($file);
103+
104+
return true
105+
? 100
106+
: (int) ((100 / 50) * 100);

0 commit comments

Comments
 (0)