function FileCommentSniff::processLicense
Process the license tag.
Parameters
\PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.:
array $tags The tokens for these tags.:
Return value
void
File
-
vendor/
squizlabs/ php_codesniffer/ src/ Standards/ PEAR/ Sniffs/ Commenting/ FileCommentSniff.php, line 530
Class
Namespace
PHP_CodeSniffer\Standards\PEAR\Sniffs\CommentingCode
protected function processLicense($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'];
$matches = [];
preg_match('/^([^\\s]+)\\s+(.*)/', $content, $matches);
if (count($matches) !== 3) {
$error = '@license tag must contain a URL and a license name';
$phpcsFile->addError($error, $tag, 'IncompleteLicense');
}
}
}