You are here

class AuthorTagSniff in Coder 8.2

Same name and namespace in other branches
  1. 8.3 coder_sniffer/DrupalPractice/Sniffs/Commenting/AuthorTagSniff.php \DrupalPractice\Sniffs\Commenting\AuthorTagSniff
  2. 8.3.x coder_sniffer/DrupalPractice/Sniffs/Commenting/AuthorTagSniff.php \DrupalPractice\Sniffs\Commenting\AuthorTagSniff

Checks the usage of @author tags.

@category PHP @package PHP_CodeSniffer @link http://pear.php.net/package/PHP_CodeSniffer

Hierarchy

  • class \DrupalPractice\Sniffs\Commenting\AuthorTagSniff implements \PHP_CodeSniffer\Sniffs\Sniff

Expanded class hierarchy of AuthorTagSniff

File

coder_sniffer/DrupalPractice/Sniffs/Commenting/AuthorTagSniff.php, line 22

Namespace

DrupalPractice\Sniffs\Commenting
View source
class AuthorTagSniff implements Sniff {

  /**
   * Returns an array of tokens this test wants to listen for.
   *
   * @return array
   */
  public function register() {
    return array(
      T_DOC_COMMENT_TAG,
    );
  }

  //end register()

  /**
   * Processes this test, when one of its tokens is encountered.
   *
   * @param PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
   * @param int                        $stackPtr  The position of the current token
   *                                              in the stack passed in $tokens.
   *
   * @return void
   */
  public function process(File $phpcsFile, $stackPtr) {
    $tokens = $phpcsFile
      ->getTokens();
    $content = $tokens[$stackPtr]['content'];
    if ($content === '@author' || $content === '@author:') {
      $warning = '@author tags are not usually used in Drupal, because over time multiple contributors will touch the code anyway';
      $phpcsFile
        ->addWarning($warning, $stackPtr, 'AuthorFound');
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AuthorTagSniff::process public function Processes this test, when one of its tokens is encountered.
AuthorTagSniff::register public function Returns an array of tokens this test wants to listen for.