Skip to content

Commit 91f6a5d

Browse files
committed
SlevomatCodingStandard.Variables.UnusedVariable: Fixed false positive
1 parent 9e5035e commit 91f6a5d

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

SlevomatCodingStandard/Sniffs/Variables/UnusedVariableSniff.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,10 @@ private function isPartOfStatementAndWithIncrementOrDecrementOperator(File $phpc
642642
return false;
643643
}
644644

645+
if ($tokens[$previousPointer]['code'] === T_OPEN_PARENTHESIS) {
646+
$previousPointer = TokenHelper::findPreviousEffective($phpcsFile, $previousPointer - 1);
647+
}
648+
645649
return in_array(
646650
$tokens[$previousPointer]['code'],
647651
array_merge([T_STRING_CONCAT, T_ECHO], Tokens::$operators, Tokens::$assignmentTokens, Tokens::$booleanOperators),

tests/Sniffs/Variables/data/unusedVariableNoErrors.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,3 +396,13 @@ function () {
396396

397397
return $map;
398398
};
399+
400+
function ($path, $name) {
401+
$count = 0;
402+
403+
while (is_file($path . '/' . $name)) {
404+
$name = $name . '-' . (++$count) . '.php';
405+
}
406+
407+
return $name;
408+
};

0 commit comments

Comments
 (0)