AuthorTagSniff.php in Coder 8.2
Same filename and directory in other branches
Namespace
DrupalPractice\Sniffs\CommentingFile
coder_sniffer/DrupalPractice/Sniffs/Commenting/AuthorTagSniff.phpView source
<?php
/**
* \DrupalPractice\Sniffs\Commenting\AuthorTagSniff.
*
* @category PHP
* @package PHP_CodeSniffer
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
namespace DrupalPractice\Sniffs\Commenting;
use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\Sniff;
/**
* Checks the usage of @author tags.
*
* @category PHP
* @package PHP_CodeSniffer
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
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');
}
}
}
//end class
Classes
Name![]() |
Description |
---|---|
AuthorTagSniff | Checks the usage of @author tags. |