Skip to content

Commit b99a3e1

Browse files
enumagkukulich
authored andcommitted
UselessParenthesesSniff: Fixed false positive
1 parent c786f09 commit b99a3e1

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

SlevomatCodingStandard/Sniffs/PHP/UselessParenthesesSniff.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
use const T_USE;
6666
use const T_VARIABLE;
6767
use const T_WHITESPACE;
68+
use const T_YIELD;
6869
use const T_YIELD_FROM;
6970

7071
class UselessParenthesesSniff implements Sniff
@@ -153,7 +154,7 @@ public function process(File $phpcsFile, $parenthesisOpenerPointer): void
153154

154155
/** @var int $pointerAfterParenthesisOpener */
155156
$pointerAfterParenthesisOpener = TokenHelper::findNextEffective($phpcsFile, $parenthesisOpenerPointer + 1);
156-
if (in_array($tokens[$pointerAfterParenthesisOpener]['code'], [T_NEW, T_CLONE, T_YIELD_FROM, T_REQUIRE, T_REQUIRE_ONCE, T_INCLUDE, T_INCLUDE_ONCE], true)) {
157+
if (in_array($tokens[$pointerAfterParenthesisOpener]['code'], [T_NEW, T_CLONE, T_YIELD, T_YIELD_FROM, T_REQUIRE, T_REQUIRE_ONCE, T_INCLUDE, T_INCLUDE_ONCE], true)) {
157158
return;
158159
}
159160

tests/Sniffs/PHP/data/uselessParenthesesNoErrors.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ public function __construct()
113113
] + $defaults('b'));
114114

115115
function () {
116+
$y = (yield whatever()) ?? $y;
116117
$y = (yield from whatever()) ?? $y;
117118
};
118119

0 commit comments

Comments
 (0)