/** * Processes this test, when one of its tokens is encountered. Overrides to relax some * requirements. * * @param PHP_CodeSniffer_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(PHP_CodeSniffer_File $phpcsFile, $stackPtr) { // Changes for joind.in $this->tags['author']['required'] = false; $this->tags['link']['required'] = false; $this->tags['version']['required'] = false; return parent::process($phpcsFile, $stackPtr); }
/** * Process the copyright tags. * * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. * @param array $tags The tokens for these tags. * * @return void */ protected function processCopyright(PHP_CodeSniffer_File $phpcsFile, array $tags) { parent::processCopyright($phpcsFile, $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(); if (preg_match('/^([0-9]{4})((.{1})([0-9]{4}))? (.+)$/', $content, $matches) !== 0) { if ($matches[3] !== '') { if ($matches[1] !== "2013" || $matches[4] !== date("Y") || $matches[5] != "Hexmedia.pl") { $fix = $phpcsFile->addFixableWarning("Not hexmedia:)", $tag, "NotHexmedia"); if (true === $fix) { $phpcsFile->fixer->replaceToken($tag + 2, sprintf("2013-%s Hexmedia.pl", date("Y"))); } } } } } //end foreach }