diff --git a/PhpCollective/Sniffs/Commenting/InlineDocBlockSniff.php b/PhpCollective/Sniffs/Commenting/InlineDocBlockSniff.php index c52995a..a69b582 100644 --- a/PhpCollective/Sniffs/Commenting/InlineDocBlockSniff.php +++ b/PhpCollective/Sniffs/Commenting/InlineDocBlockSniff.php @@ -32,8 +32,14 @@ public function register(): array public function process(File $phpcsFile, $stackPointer): void { $tokens = $phpcsFile->getTokens(); - $startIndex = $phpcsFile->findNext(T_OPEN_CURLY_BRACKET, $stackPointer + 1); - if (!$startIndex || empty($tokens[$startIndex]['bracket_closer'])) { + + // Skip abstract methods and interface methods (no body) + if (empty($tokens[$stackPointer]['scope_opener'])) { + return; + } + + $startIndex = $tokens[$stackPointer]['scope_opener']; + if (empty($tokens[$startIndex]['bracket_closer'])) { return; } @@ -231,7 +237,7 @@ protected function findErrors(File $phpcsFile, int $contentIndex, bool $isSingle protected function hasReturnAsFollowingToken(File $phpcsFile, int $contentIndex): bool { $nextIndex = $phpcsFile->findNext(Tokens::$emptyTokens, $contentIndex + 1, null, true); - if (!$nextIndex) { + if ($nextIndex === false) { return false; }