getTokens(); $ignore = [ \T_PUBLIC => \T_PUBLIC, \T_PRIVATE => \T_PRIVATE, \T_PROTECTED => \T_PROTECTED, \T_VAR => \T_VAR, \T_NULL => \T_NULL, \T_STATIC => \T_STATIC, \T_TYPE_UNION => \T_TYPE_UNION, \T_WHITESPACE => \T_WHITESPACE, \T_STRING => \T_STRING, \T_NS_SEPARATOR => \T_NS_SEPARATOR, \T_NULLABLE => \T_NULLABLE, ]; $commentEnd = MemberVarUtility::findCommentEndWithoutAttributes($tokens, $ignore, $stackPtr); // this error is copied from above, as it comes with a needed early return if ( $commentEnd === false || ($tokens[$commentEnd]['code'] !== \T_DOC_COMMENT_CLOSE_TAG && $tokens[$commentEnd]['code'] !== \T_COMMENT) ) { $phpcsFile->addError('Missing member variable doc comment', $stackPtr, 'Missing'); return; } $commentStart = $tokens[$commentEnd]['comment_opener']; $foundVar = null; foreach ($tokens[$commentStart]['comment_tags'] as $tag) { if ( $tokens[$tag]['content'] === '@var' || $tokens[$tag]['content'] === '@inheritDoc' ) { $foundVar = $tag; } } // The @var tag is the only one we require. if ($foundVar === null) { $error = 'Missing @var or @inheritDoc tag in member variable comment'; $phpcsFile->addWarning($error, $commentEnd, 'MissingVarOrInheritDoc'); return; } // remove the error reporting from base class, as it does not accept union types // https://github.com/squizlabs/PHP_CodeSniffer/pull/3757 $oldSeverity = $phpcsFile->ruleset->ruleset['DigiComp.Commenting.VariableComment.Missing']['severity'] ?? null; $phpcsFile->ruleset->ruleset['DigiComp.Commenting.VariableComment.Missing']['severity'] = 0; parent::processMemberVar($phpcsFile, $stackPtr); if ($oldSeverity !== null) { $phpcsFile->ruleset->ruleset['DigiComp.Commenting.VariableComment.Missing']['severity'] = $oldSeverity; } else { unset($phpcsFile->ruleset->ruleset['DigiComp.Commenting.VariableComment.Missing']['severity']); } } }