Skip to content

Commit edb063f

Browse files
committed
fix grouped tag
1 parent 681d920 commit edb063f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Travelopia-WordPress/Sniffs/Whitespace/GroupedConstSniff.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ public function process( File $phpcsFile, $stackPtr ): void {
4343

4444
// Check if we don't have 2 newline characters before `const` statement.
4545
if ( ! str_ends_with( $tokens[ $stackPtr - 1 ]['content'], "\n" ) || "\n" !== $tokens[ $stackPtr - 2 ]['content'] ) {
46+
// Get the previous doc comment.
47+
$prev_doc_comment = $phpcsFile->findPrevious( [ T_DOC_COMMENT_CLOSE_TAG ], $stackPtr - 1 );
48+
49+
// If the previous line is a doc comment, ignore this.
50+
if (
51+
! is_int( $prev_doc_comment )
52+
|| ( T_DOC_COMMENT_CLOSE_TAG === $tokens[ $prev_doc_comment ]['code'] && $tokens[ $prev_doc_comment ]['line'] === $tokens[ $stackPtr ]['line'] - 1 )
53+
) {
54+
return;
55+
}
56+
4657
// Get the previous `const` statement.
4758
$prev_const = $phpcsFile->findPrevious( [ T_CONST ], $stackPtr - 1 );
4859

0 commit comments

Comments
 (0)