diff --git a/Backdrop/Sniffs/Commenting/InlineCommentSniff.php b/Backdrop/Sniffs/Commenting/InlineCommentSniff.php index 6cbc2e9..58a3e14 100644 --- a/Backdrop/Sniffs/Commenting/InlineCommentSniff.php +++ b/Backdrop/Sniffs/Commenting/InlineCommentSniff.php @@ -179,6 +179,14 @@ public function process(File $phpcsFile, $stackPtr) } } + if ($tokens[$stackPtr]['type'] === 'T_COMMENT' && strpos($tokens[$stackPtr]['content'], '@var') !== FALSE) { + // Enforce inline type hints to the syntax most widely supported by IDEs and tools. + if (strpos($tokens[$stackPtr]['content'], '/**') !== 0) { + $error = 'Inline type hint comments must be in the form "/** @var ... */".'; + $phpcsFile->addError($error, $stackPtr, 'InvalidTypeHint'); + } + } + // Only want inline comments. if (substr($tokens[$stackPtr]['content'], 0, 2) !== '//') { return;