Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. FileCommentSniff.php

function FileCommentSniff::processVersion

Process the version tag.

Parameters

\PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.:

array $tags The tokens for these tags.:

Return value

void

1 method overrides FileCommentSniff::processVersion()
ClassCommentSniff::processVersion in vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Sniffs/Commenting/ClassCommentSniff.php
Process the version tag.

File

vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php, line 559

Class

FileCommentSniff

Namespace

PHP_CodeSniffer\Standards\PEAR\Sniffs\Commenting

Code

protected function processVersion($phpcsFile, array $tags) {
    $tokens = $phpcsFile->getTokens();
    foreach ($tags as $tag) {
        if ($tokens[$tag + 2]['code'] !== T_DOC_COMMENT_STRING) {
            // No content.
            continue;
        }
        $content = $tokens[$tag + 2]['content'];
        if (strstr($content, 'CVS:') === false && strstr($content, 'SVN:') === false && strstr($content, 'GIT:') === false && strstr($content, 'HG:') === false) {
            $error = 'Invalid version "%s" in file comment; consider "CVS: <cvs_id>" or "SVN: <svn_id>" or "GIT: <git_id>" or "HG: <hg_id>" instead';
            $data = [
                $content,
            ];
            $phpcsFile->addWarning($error, $tag, 'InvalidVersion', $data);
        }
    }
}
RSS feed
Powered by Drupal