Пример #1
0
 /**
  * Process the copyright tag.
  *
  * @param int $errorPos The line number where the error occurs.
  *
  * @return void
  */
 private function _processCopyright($errorPos)
 {
     $copyright = $this->commentParser->getCopyRight();
     if ($copyright !== null) {
         $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
 }
Пример #2
0
 /**
  * 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
  */
 private function _processCopyright($errorPos)
 {
     $copyright = $this->commentParser->getCopyRight();
     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})? (AVOIR)$/', $content) === 0) {
                 $error = 'Expected "2006-2007 AVOIR" for copyright declaration';
                 $this->currentFile->addError($error, $errorPos);
             }
         }
     }
 }