Skip to content

Commit 0e1efcd

Browse files
committed
Fix docblock sniff.
1 parent 07e12c7 commit 0e1efcd

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

PhpCollective/Sniffs/Commenting/DocBlockVarSniff.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,16 @@ public function process(File $phpCsFile, $stackPointer): void
4040
$tokens = $phpCsFile->getTokens();
4141

4242
$previousIndex = $phpCsFile->findPrevious(Tokens::$emptyTokens, $stackPointer - 1, null, true);
43+
44+
while ($previousIndex && in_array($tokens[$previousIndex]['code'], [T_STRING, T_NULLABLE, T_NULL, T_TYPE_UNION], true)) {
45+
$previousIndex = $phpCsFile->findPrevious(Tokens::$emptyTokens, $previousIndex - 1, null, true);
46+
}
47+
4348
if ($previousIndex && $tokens[$previousIndex]['code'] === T_STATIC) {
4449
$previousIndex = $phpCsFile->findPrevious(Tokens::$emptyTokens, $previousIndex - 1, null, true);
4550
}
4651

52+
// Skip inline comments here
4753
if (!$this->isGivenKind([T_PUBLIC, T_PROTECTED, T_PRIVATE], $tokens[$previousIndex])) {
4854
return;
4955
}

0 commit comments

Comments
 (0)