Skip to content

Commit debe76d

Browse files
committed
UselessParenthesesSniff: Fixed false positive
1 parent c48e4d4 commit debe76d

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

SlevomatCodingStandard/Sniffs/PHP/UselessParenthesesSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public function process(File $phpcsFile, $parenthesisOpenerPointer): void
159159
$pointerAfterParenthesisOpener = TokenHelper::findNextEffective($phpcsFile, $parenthesisOpenerPointer + 1);
160160
if (in_array(
161161
$tokens[$pointerAfterParenthesisOpener]['code'],
162-
[T_NEW, T_CLONE, T_YIELD, T_YIELD_FROM, T_REQUIRE, T_REQUIRE_ONCE, T_INCLUDE, T_INCLUDE_ONCE],
162+
[T_NEW, T_CLONE, T_YIELD, T_YIELD_FROM, T_REQUIRE, T_REQUIRE_ONCE, T_INCLUDE, T_INCLUDE_ONCE, T_ARRAY_CAST],
163163
true
164164
)) {
165165
return;

tests/Sniffs/PHP/data/uselessParenthesesNoErrors.php

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

161161
$whatever = (null !== $a = $b->call());
162162

163+
$key = ((array) $table->getPrimaryKey())[0];
164+
163165
// Must be last
164166
return true
165167
? 100

0 commit comments

Comments
 (0)