Closed ihorvorotnov closed 2 years ago
The fix can be wrapper for the Generic.Commenting.DocComment
sniff which skip the /** @lang CSS */
PHPDocs.
Quick solution:
<?php
namespace WPForms\Sniffs\Generic\Commenting\DocComment;
use PHP_CodeSniffer\Files\File;
class DocCommentSniff extends \PHP_CodeSniffer\Standards\Generic\Sniffs\Commenting\DocCommentSniff {
public function process( File $phpcsFile, $stackPtr ) {
$tokens = $phpcsFile->getTokens();
if (
isset( $tokens[ $stackPtr ]['comment_closer'] ) === false
|| (
$tokens[ $tokens[ $stackPtr ]['comment_closer'] ]['content'] === ''
&& $tokens[ $stackPtr ]['comment_closer'] === ( $phpcsFile->numTokens - 1 )
)
) {
// Don't process an unfinished comment during live coding.
return;
}
$commentEnd = $tokens[ $stackPtr ]['comment_closer'];
$empty = [
T_DOC_COMMENT_WHITESPACE,
T_DOC_COMMENT_STAR,
];
$short = $phpcsFile->findNext( $empty, ( $stackPtr + 1 ), $commentEnd, true );
if ( $short && $tokens[ $short ]['code'] === T_DOC_COMMENT_TAG && $tokens[ $short ]['content'] === '@lang' ) {
return;
}
parent::process( $phpcsFile, $stackPtr );
}
}
Some sniffs are triggered in specific cases that should be excluded. I'll update the list during further testing.
/** @lang <Language> */
triggersGeneric.Commenting.DocComment.MissingShort
More exclusions may be added later...