PEAR_Sniffs_Commenting_FileCommentSniff::processAuthor PHP Method

processAuthor() protected method

Process the author tag(s) that this header comment has.
protected processAuthor ( 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 processAuthor(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'];
            $local = '\\da-zA-Z-_+';
            // Dot character cannot be the first or last character in the local-part.
            $localMiddle = $local . '.\\w';
            if (preg_match('/^([^<]*)\\s+<([' . $local . ']([' . $localMiddle . ']*[' . $local . '])*@[\\da-zA-Z][-.\\w]*[\\da-zA-Z]\\.[a-zA-Z]{2,7})>$/', $content) === 0) {
                $error = 'Content of the @author tag must be in the form "Display Name <[email protected]>"';
                $phpcsFile->addError($error, $tag, 'InvalidAuthors');
            }
        }
    }