/** * Copyright tag must be in the form '2006-YYYY Squiz Pty Ltd (ABN 77 084 670 600)'. * * @param int $errorPos The first token on the line where the error occurs. * * @return void */ protected function processCopyrights($errorPos) { $copyrights = $this->commentParser->getCopyrights(); $copyright = $copyrights[0]; if ($copyright === null) { return; } $content = $copyright->getContent(); if (empty($content) === true) { $error = 'Content missing for @copyright tag in file comment'; $this->currentFile->addError($error, $errorPos, 'MissingCopyright'); } else { if (preg_match('/^([0-9]{4})(-[0-9]{4})? (Squiz Pty Ltd \\(ABN 77 084 670 600\\))$/', $content) === 0) { $error = 'Expected "xxxx-xxxx Squiz Pty Ltd (ABN 77 084 670 600)" for copyright declaration'; $fix = $this->currentFile->addFixableError($error, $errorPos, 'IncorrectCopyright'); if ($fix === true && $this->currentFile->fixer->enabled === true) { $tokens = $this->currentFile->getTokens(); $matches = array(); preg_match('/^(\\s*\\*\\s+@copyright\\s+)(([0-9]{4})(-[0-9]{4})?)?.*$/', $tokens[$errorPos]['content'], $matches); if (isset($matches[2]) === false) { $matches[2] = date('Y'); } $expected = $matches[1] . $matches[2] . ' Squiz Pty Ltd (ABN 77 084 670 600)' . $this->currentFile->eolChar; $this->currentFile->fixer->replaceToken($errorPos, $expected); } } } //end if }
/** * Process the copyright tags. * * @param int $commentStart The position in the stack where * the comment started. * * @return void */ protected function processCopyrights($commentStart) { $copyrights = $this->commentParser->getCopyrights(); foreach ($copyrights as $copyright) { $errorPos = $commentStart + $copyright->getLine(); $content = $copyright->getContent(); if ($content !== '') { $matches = array(); if (preg_match('/^([0-9]{4})((.{1})([0-9]{4}))? (.+)$/', $content, $matches) !== 0) { // Check earliest-latest year order. if ($matches[3] !== '') { if ($matches[3] !== '-') { $error = 'A hyphen must be used between the earliest and latest year'; $this->currentFile->addError($error, $errorPos); } if ($matches[4] !== '' && $matches[4] < $matches[1]) { $error = "Invalid year span \"{$matches['1']}{$matches['3']}{$matches['4']}\" found; consider \"{$matches['4']}-{$matches['1']}\" instead"; $this->currentFile->addWarning($error, $errorPos); } } } else { $error = '@copyright tag must contain a year and the name of the copyright holder'; $this->currentFile->addError($error, $errorPos); } } else { $error = '@copyright tag must contain a year and the name of the copyright holder'; $this->currentFile->addError($error, $errorPos); } //end if } //end if }
protected function processCopyrights($commentStart) { $copyrights = $this->commentParser->getCopyrights(); foreach ($copyrights as $copyright) { $errorPos = $commentStart + $copyright->getLine(); $content = $copyright->getContent(); if (!empty($content)) { if ($this->isInternalProject()) { $bYear = '2011'; $eYear = @date('Y'); $text = 'Copyright (c) ' . ($bYear == $eYear ? $bYear : $bYear . '-' . $eYear) . ' Creative Development LLC <*****@*****.**>. All rights reserved'; $eYear2 = $eYear - 1; $text2 = 'Copyright (c) ' . ($bYear == $eYear2 ? $bYear : $bYear . '-' . $eYear2) . ' Creative Development LLC <*****@*****.**>. All rights reserved'; if ($content !== $text && $content !== $text2) { $error = 'Content of the @copyright tag must be in the form "' . $text . '"'; $this->currentFile->addError($this->getReqPrefix($this->getReqCode($this->reqCodesWrongFormat, 'copyright')) . $error, $errorPos); } } } else { $error = "Content missing for @copyright tag in " . $this->docBlock . " comment"; $this->currentFile->addError($this->getReqPrefix($this->reqCodeEmpty) . ' ' . $error, $errorPos); } } //end if }
/** * Process the copyright tags * * @param integer $errorPos The line number where the error occurs * @return void */ protected function _processCopyrights($errorPos) { $copyrights = $this->_commentParser->getCopyrights(); if (count($copyrights) > 1) { $error = 'Only one @copyright tag allowed'; $this->_currentFile->addError($error, $errorPos, 'OneCopyrightTagAllowedFileComment'); } else { $content = $copyrights[0]->getContent(); if ($content !== 'Copyright (c) 2005-' . date('Y') . ' Zend Technologies USA Inc. (http://www.zend.com)') { $error = "@copyright tag must be 'Copyright (c) 2005-" . date('Y') . " Zend Technologies USA Inc. (http://www.zend.com)'"; $this->_currentFile->addError($error, $errorPos, 'CopyrightTagFileComment'); } } }
/** * Copyright tag must be in the form '2006-YYYY Squiz Pty Ltd (ABN 77 084 670 600)'. * * @param int $errorPos The line number where the error occurs. * * @return void */ protected function processCopyrights($errorPos) { $copyrights = $this->commentParser->getCopyrights(); $copyright = $copyrights[0]; if ($copyright !== null) { $content = $copyright->getContent(); if (empty($content) === true) { $error = 'Content missing for @copyright tag in file comment'; $this->currentFile->addError($error, $errorPos); } else { if (preg_match('/^([0-9]{4})-([0-9]{4})? (Squiz Pty Ltd \\(ABN 77 084 670 600\\))$/', $content) === 0) { $error = 'Expected "2006-2007 Squiz Pty Ltd (ABN 77 084 670 600)" for copyright declaration'; $this->currentFile->addError($error, $errorPos); } } } }
/** * Copyright tag must be in the form '2006-YYYY Hotelsnl Pty Ltd (ABN 77 084 670 600)'. * * @param int $errorPos The line number where the error occurs. * * @return void */ protected function processCopyrights($errorPos) { $copyrights = $this->commentParser->getCopyrights(); $copyright = $copyrights[0]; if ($copyright !== null) { $content = $copyright->getContent(); if (empty($content) === true) { $error = 'Content missing for @copyright tag in file comment'; $this->currentFile->addError($error, $errorPos, 'MissingCopyright'); } else { if (preg_match('/^([0-9]{4})? (Hotels.nl)$/', $content) === 0) { $error = 'Expected "yyyy Hotels.nl" for copyright declaration'; $this->currentFile->addError($error, $errorPos, 'IncorrectCopyright'); } } } }
/** * Copyright tag must be in the form "2009-xxxx Vanilla Forums Inc.". * * @param int $errorPos The line number where the error occurs. * * @return void */ protected function processCopyrights($errorPos) { $copyrights = $this->commentParser->getCopyrights(); if (count($copyrights) > 1) { $vanillaFound = false; foreach ($copyrights as $copyright) { $content = $copyright->getContent(); if (empty($content) === true) { $error = 'Content missing for @copyright tag in file comment'; $this->currentFile->addError($error, $errorPos, 'MissingCopyright'); } date_default_timezone_set('UTC'); preg_match('/^2009\\-(\\d{4}) Vanilla Forums Inc./', $content, $matches); if (!empty($matches) && $matches[1] == date('Y', time())) { $vanillaFound = true; } } if (!$vanillaFound) { $error = 'Expected "2009-' . date('Y') . ' Vanilla Forums Inc." for copyright declaration'; $this->currentFile->addError($error, $errorPos, 'IncorrectCopyright'); } } elseif ($copyrights[0] !== null) { $copyright = $copyrights[0]; $license = $this->commentParser->getLicense(); if ($license === null) { $error = 'Content missing for @license tag in file comment'; $this->currentFile->addError($error, $errorPos, 'MissingLicense'); } $content = $copyright->getContent(); if (empty($content) === true) { $error = 'Content missing for @copyright tag in file comment'; $this->currentFile->addError($error, $errorPos, 'MissingCopyright'); } date_default_timezone_set('UTC'); preg_match('/^2009\\-(\\d{4}) Vanilla Forums Inc.$/', $content, $matches); if (empty($matches) || $matches[1] != date('Y', time())) { $error = 'Expected "2009-' . date('Y') . ' Vanilla Forums Inc." for copyright declaration'; $this->currentFile->addError($error, $errorPos, 'IncorrectCopyright'); } } }