class AuthorTagSniff in Coder 8.2
Same name and namespace in other branches
- 8.3 coder_sniffer/DrupalPractice/Sniffs/Commenting/AuthorTagSniff.php \DrupalPractice\Sniffs\Commenting\AuthorTagSniff
- 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\CommentingView 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
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AuthorTagSniff:: |
public | function | Processes this test, when one of its tokens is encountered. | |
AuthorTagSniff:: |
public | function | Returns an array of tokens this test wants to listen for. |