Skip to content

Commit aa0cfc9

Browse files
v.fateevkukulich
authored andcommitted
EnumCaseSpacingSniff: Fixed internal error
1 parent 479025e commit aa0cfc9

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

SlevomatCodingStandard/Sniffs/Classes/EnumCaseSpacingSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected function isNextMemberValid(File $phpcsFile, int $pointer): bool
3434

3535
$nextPointer = TokenHelper::findNext($phpcsFile, [T_FUNCTION, T_CONST, T_VARIABLE, T_USE, T_ENUM_CASE], $pointer + 1);
3636

37-
return $tokens[$nextPointer]['code'] === T_ENUM_CASE;
37+
return $nextPointer !== null && $tokens[$nextPointer]['code'] === T_ENUM_CASE;
3838
}
3939

4040
protected function addError(File $phpcsFile, int $pointer, int $minExpectedLines, int $maxExpectedLines, int $found): bool

tests/Sniffs/Classes/data/enumCaseSpacingNoErrors.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,10 @@ enum TestClass
4444

4545
case BAR;
4646
}
47+
48+
enum TestClass1
49+
{
50+
case FOO;
51+
52+
use TestTrait;
53+
}

0 commit comments

Comments
 (0)