PEAR_Sniffs_Commenting_FileCommentSniff::processLicense PHP Method

processLicense() protected method

Process the license tag.
protected processLicense ( PHP_CodeSniffer_File $phpcsFile, array $tags ) : void
$phpcsFile PHP_CodeSniffer_File The file being scanned.
$tags array The tokens for these tags.
return void
    protected function processLicense(PHP_CodeSniffer_File $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 = array();
            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');
            }
        }
    }