Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected function isNextMemberValid(File $phpcsFile, int $pointer): bool

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

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

protected function addError(File $phpcsFile, int $pointer, int $minExpectedLines, int $maxExpectedLines, int $found): bool
Expand Down
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
14 changes: 14 additions & 0 deletions tests/Sniffs/Classes/data/constantSpacingNoErrors.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ class TestClass
private const CONSTANT_2 = 'bar';
}

class TestClass1
{
public const CONSTANT_1 = 'foo';

use TestTrait;
}

enum A: string
{
public const X = [];
Expand All @@ -62,3 +69,10 @@ enum A: string

case B = 'b';
}

enum B: string
{
public const X = [];

case A = 'a';
}
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;
}
Loading