Skip to content

Commit

Permalink
EnumCaseSpacingSniff: Fixed internal error
Browse files Browse the repository at this point in the history
  • Loading branch information
v.fateev authored and kukulich committed Jan 1, 2025
1 parent 479025e commit aa0cfc9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected function isNextMemberValid(File $phpcsFile, int $pointer): bool

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

return $tokens[$nextPointer]['code'] === T_ENUM_CASE;
return $nextPointer !== null && $tokens[$nextPointer]['code'] === T_ENUM_CASE;
}

protected function addError(File $phpcsFile, int $pointer, int $minExpectedLines, int $maxExpectedLines, int $found): bool
Expand Down
7 changes: 7 additions & 0 deletions tests/Sniffs/Classes/data/enumCaseSpacingNoErrors.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,10 @@ enum TestClass

case BAR;
}

enum TestClass1
{
case FOO;

use TestTrait;
}

0 comments on commit aa0cfc9

Please sign in to comment.