Skip to content

Commit 7b33fb1

Browse files
committed
RequireOnlyStandaloneIncrementAndDecrementOperatorsSniff: Fixed false positives
1 parent 48dc21a commit 7b33fb1

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

SlevomatCodingStandard/Helpers/IdentificatorHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ private static function getStartPointerBeforeVariablePart(File $phpcsFile, int $
120120
return self::getStartPointerBeforeVariablePart($phpcsFile, $tokens[$previousPointer]['bracket_opener']);
121121
}
122122

123-
if ($tokens[$previousPointer]['code'] === T_VARIABLE) {
123+
if (in_array($tokens[$previousPointer]['code'], [T_VARIABLE, T_STRING], true)) {
124124
return self::getStartPointerBeforeVariablePart($phpcsFile, $previousPointer);
125125
}
126126

tests/Sniffs/Operators/data/requireOnlyStandaloneIncrementAndDecrementOperatorsNoErrors.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,5 @@ function ($x) {
3535
++$a['a'];
3636
$a['a']--;
3737
--$a['a'];
38+
39+
$this->typeCounter[$value]++;

0 commit comments

Comments
 (0)