protected function checkLineLength(PHP_CodeSniffer_File $phpcsFile, $tokens, $stackPtr) {
    if (isset(PHP_CodeSniffer_Tokens::$commentTokens[$tokens[$stackPtr - 1]['code']]) === TRUE) {
      $doc_comment_tag = $phpcsFile->findFirstOnLine(T_DOC_COMMENT_TAG, $stackPtr - 1);
      if ($doc_comment_tag !== FALSE) {
        // Allow doc comment tags such as long @param tags to exceed the 80
        // character limit.
        return;
      }
      if ($tokens[($stackPtr - 1)]['code'] === T_COMMENT
        && (preg_match('/^[[:space:]]*\/\/ @.+/', $tokens[($stackPtr - 1)]['content']) === 1
          // Allow anything that does not contain spaces (like URLs) to be
          // longer.
          || strpos(trim($tokens[($stackPtr - 1)]['content'], "/ \n"), ' ') === FALSE)
      ) {
        // Allow @link and @see documentation to exceed the 80 character
        // limit.
        return;
      }

      // Code examples between @code and @endcode are allowed to exceed 80
      // characters.
      if (isset($tokens[$stackPtr]) === TRUE && $tokens[$stackPtr]['code'] === T_DOC_COMMENT_WHITESPACE) {
        $tag = $phpcsFile->findPrevious(array(
          T_DOC_COMMENT_TAG,
          T_DOC_COMMENT_OPEN_TAG,
        ), $stackPtr - 1);
        if ($tokens[$tag]['content'] === '@code') {
          return;
        }
      }

      // Drupal 8 annotations can have long translatable descriptions and we
      // allow them to exceed 80 characters.
      if ($tokens[$stackPtr - 2]['code'] === T_DOC_COMMENT_STRING && strpos($tokens[$stackPtr - 2]['content'], '@Translation(') !== FALSE) {
        return;
      }

      // Allow comments preceded by the line with @code and ended by the line
      // with @endcode to be excluded.
      if ($this->isInCodeExample($phpcsFile, $stackPtr) === TRUE) {
        return;
      }

      parent::checkLineLength($phpcsFile, $tokens, $stackPtr);
    }
  }
protected function checkLineLength(PHP_CodeSniffer_File $phpcsFile, $tokens, $stackPtr) {
    if (isset(PHP_CodeSniffer_Tokens::$commentTokens[$tokens[$stackPtr - 1]['code']]) === TRUE) {
      $doc_comment_tag = $phpcsFile->findFirstOnLine(T_DOC_COMMENT_TAG, $stackPtr - 1);
      if ($doc_comment_tag !== FALSE) {
        // Allow doc comment tags such as long @param tags to exceed the 80
        // character limit.
        return;
      }
      if ($tokens[($stackPtr - 1)]['code'] === T_COMMENT
        && (preg_match('/^[[:space:]]*\/\/ @.+/', $tokens[($stackPtr - 1)]['content']) === 1
          // Allow anything that does not contain spaces (like URLs) to be
          // longer.
          || strpos(trim($tokens[($stackPtr - 1)]['content'], "/ \n"), ' ') === FALSE)
      ) {
        // Allow @link and @see documentation to exceed the 80 character
        // limit.
        return;
      }

      // Code examples between @code and @endcode are allowed to exceed 80
      // characters.
      if (isset($tokens[$stackPtr]) === TRUE && $tokens[$stackPtr]['code'] === T_DOC_COMMENT_WHITESPACE) {
        $tag = $phpcsFile->findPrevious(array(
          T_DOC_COMMENT_TAG,
          T_DOC_COMMENT_OPEN_TAG,
        ), $stackPtr - 1);
        if ($tokens[$tag]['content'] === '@code') {
          return;
        }
      }

      // Drupal 8 annotations can have long translatable descriptions and we
      // allow them to exceed 80 characters.
      if ($tokens[$stackPtr - 2]['code'] === T_DOC_COMMENT_STRING && strpos($tokens[$stackPtr - 2]['content'], '@Translation(') !== FALSE) {
        return;
      }

      // Allow comments preceded by the line with @code and ended by the line
      // with @endcode to be excluded.
      if ($this->isInCodeExample($phpcsFile, $stackPtr) === TRUE) {
        return;
      }

      parent::checkLineLength($phpcsFile, $tokens, $stackPtr);
    }
  }
protected function checkLineLength ( PHP_CodeSniffer_File $ phpcsFile , $ tokens , $ stackPtr ) { if ( isset ( PHP_CodeSniffer_Tokens :: $ commentTokens [ $ tokens [ $ stackPtr - 1 ] [ 'code' ] ] ) === TRUE ) { $ doc_comment_tag = $ phpcsFile -> findFirstOnLine ( T_DOC_COMMENT_TAG , $ stackPtr - 1 ) ; if ( $ doc_comment_tag !== FALSE ) { // Allow doc comment tags such as long @param tags to exceed the 80 // character limit. return ; } if ( $ tokens [ ( $ stackPtr - 1 ) ] [ 'code' ] === T_COMMENT && ( preg_match ( '/^[[:space:]]*\/\/ @.+/' , $ tokens [ ( $ stackPtr - 1 ) ] [ 'content' ] ) === 1 // Allow anything that does not contain spaces (like URLs) to be // longer. || strpos ( trim ( $ tokens [ ( $ stackPtr - 1 ) ] [ 'content' ] , "/ \n" ) , ' ' ) === FALSE ) ) { // Allow @link and @see documentation to exceed the 80 character // limit. return ; } // Code examples between @code and @endcode are allowed to exceed 80 // characters. if ( isset ( $ tokens [ $ stackPtr ] ) === TRUE && $ tokens [ $ stackPtr ] [ 'code' ] === T_DOC_COMMENT_WHITESPACE ) { $ tag = $ phpcsFile -> findPrevious ( array ( T_DOC_COMMENT_TAG , T_DOC_COMMENT_OPEN_TAG , ) , $ stackPtr - 1 ) ; if ( $ tokens [ $ tag ] [ 'content' ] === '@code' ) { return ; } } // Drupal 8 annotations can have long translatable descriptions and we // allow them to exceed 80 characters. if ( $ tokens [ $ stackPtr - 2 ] [ 'code' ] === T_DOC_COMMENT_STRING && strpos ( $ tokens [ $ stackPtr - 2 ] [ 'content' ] , '@Translation(' ) !== FALSE ) { return ; } // Allow comments preceded by the line with @code and ended by the line // with @endcode to be excluded. if ( $ this -> isInCodeExample ( $ phpcsFile , $ stackPtr ) === TRUE ) { return ; } parent :: checkLineLength ( $ phpcsFile , $ tokens , $ stackPtr ) ; } }
Checks if a line is too long.

@param PHP_CodeSniffer_File $phpcsFile The file being scanned.
@param array $tokens The token stack.
@param int $stackPtr The first token on the next line.

@return void
Checks if a line is too long .