Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Backdrop/Sniffs/Commenting/InlineCommentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down