You are here

protected function Drupal_Sniffs_Files_LineLengthSniff::checkLineLength in Coder 7.2

Checks if a line is too long.

Parameters

PHP_CodeSniffer_File $phpcsFile The file being scanned.:

int $stackPtr The token at the end of the line.:

string $lineContent The content of the line.:

Return value

void

File

coder_sniffer/Drupal/Sniffs/Files/LineLengthSniff.php, line 50

Class

Drupal_Sniffs_Files_LineLengthSniff
Checks comment lines in the file, and throws warnings if they are over 80 characters in length.

Code

protected function checkLineLength(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $lineContent) {
  $tokens = $phpcsFile
    ->getTokens();
  if ($tokens[$stackPtr]['code'] === T_DOC_COMMENT || $tokens[$stackPtr]['code'] === T_COMMENT) {
    if (preg_match('/^[[:space:]]*(\\/\\*)?\\*[[:space:]]*@link.*@endlink[[:space:]]*/', $lineContent) === 1) {

      // Allow @link documentation to exceed the 80 character limit.
      return;
    }
    if (preg_match('/^[[:space:]]*((\\/\\*)?\\*|\\/\\/)[[:space:]]*@see.*/', $lineContent) === 1) {

      // Allow @see documentation to exceed the 80 character limit.
      return;
    }
    parent::checkLineLength($phpcsFile, $stackPtr, $lineContent);
  }
}