/** * Process the author tag(s) that this header comment has. * * This function is different from other _process functions * as $authors is an array of SingleElements, so we work out * the errorPos for each element separately * * @param int $commentStart The position in the stack where * the comment started. * * @return void */ protected function processAuthors($commentStart) { $authors = $this->commentParser->getAuthors(); // Report missing return. if (empty($authors) === false) { foreach ($authors as $author) { $errorPos = $commentStart + $author->getLine(); $content = $author->getContent(); if ($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 <*****@*****.**>"'; $this->currentFile->addError($error, $errorPos); } } else { $docBlock = get_class($this) === 'PEAR_Sniffs_Commenting_FileCommentSniff' ? 'file' : 'class'; $error = "Content missing for @author tag in {$docBlock} comment"; $this->currentFile->addError($error, $errorPos); } } } }
/** * Author tag must be 'Squiz Pty Ltd <*****@*****.**>'. * * @param int $errorPos The first token on the line where the error occurs. * * @return void */ protected function processAuthors($errorPos) { $authors = $this->commentParser->getAuthors(); if (empty($authors) === true) { return; } $author = $authors[0]; $content = $author->getContent(); if (empty($content) === true) { $error = 'Content missing for @author tag in file comment'; $this->currentFile->addError($error, $errorPos, 'MissingAuthor'); } else { if ($content !== 'Squiz Pty Ltd <*****@*****.**>') { $error = 'Expected "Squiz Pty Ltd <*****@*****.**>" for author tag'; $fix = $this->currentFile->addFixableError($error, $errorPos, 'IncorrectAuthor'); if ($fix === true && $this->currentFile->fixer->enabled === true) { $tokens = $this->currentFile->getTokens(); $matches = array(); preg_match('/^(\\s*\\*\\s+@author\\s+).*$/', $tokens[$errorPos]['content'], $matches); $expected = $matches[1] . 'Squiz Pty Ltd <*****@*****.**>' . $this->currentFile->eolChar; $this->currentFile->fixer->replaceToken($errorPos, $expected); } } } }
/** * Author tag must be 'Squiz Pty Ltd <*****@*****.**>'. * * @param int $errorPos The line number where the error occurs. * * @return void */ protected function processAuthors($errorPos) { $authors = $this->commentParser->getAuthors(); if (empty($authors) === false) { $author = $authors[0]; $content = $author->getContent(); if (empty($content) === true) { $error = 'Content missing for @author tag in file comment'; $this->currentFile->addError($error, $errorPos); } else { if ($content !== 'Squiz Pty Ltd <*****@*****.**>') { $error = 'Expected "Squiz Pty Ltd <*****@*****.**>" for author tag'; $this->currentFile->addError($error, $errorPos); } } } }
/** * Author tag must be 'Hotelsnl Pty Ltd <*****@*****.**>'. * * @param int $errorPos The line number where the error occurs. * * @return void */ protected function processAuthors($errorPos) { $authors = $this->commentParser->getAuthors(); if (empty($authors) === false) { $author = $authors[0]; $content = $author->getContent(); if (empty($content) === true) { $error = 'Content missing for @author tag in file comment'; $this->currentFile->addError($error, $errorPos, 'MissingAuthor'); } else { if ($content !== 'Hotels.nl') { $error = 'Expected "Hotels.nl"'; $this->currentFile->addError($error, $errorPos, 'IncorrectAuthor'); } } } }
protected function processAuthor($commentStart) { $authors = $this->commentParser->getAuthors(); // Report missing return. if (empty($authors) === false) { foreach ($authors as $author) { $errorPos = $commentStart + $author->getLine(); $content = $author->getContent(); if ($this->isInternalProject() && $content !== 'Creative Development LLC <*****@*****.**>') { $error = 'Content of the @author tag must be in the form "Creative Development LLC <*****@*****.**>"'; $this->currentFile->addError($this->getReqPrefix($this->getReqCode($this->reqCodesWrongFormat, 'author')) . $error, $errorPos); } elseif (!$content) { $error = "Content missing for @author tag in " . $this->docBlock . " comment"; $this->currentFile->addError($this->getReqPrefix($this->reqCodeEmpty) . ' ' . $error, $errorPos); } } } }
/** * Author tag must be 'Some Person <*****@*****.**>'. * * @param int $errorPos The line number where the error occurs. * * @return void */ private function _processAuthors($errorPos) { $commentStart = NULL; $authors = $this->commentParser->getAuthors(); // Report missing return. if (empty($authors) === false) { foreach ($authors as $author) { $errorPos = $commentStart + $author->getLine(); $content = $author->getContent(); if ($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 <*****@*****.**>"'; $this->currentFile->addError($error, $errorPos); } } else { $docBlock = get_class($this) === 'Chisimba_Sniffs_Commenting_FileCommentSniff' ? 'file' : 'class'; $error = "Content missing for @author tag in {$docBlock} comment"; $this->currentFile->addError($error, $errorPos); } } } /*$authors = $this->commentParser->getAuthors(); if (empty($authors) === false) { $author = $authors[0]; $content = $author->getContent(); if (empty($content) === true) { $error = 'Content missing for @author tag in file comment'; $this->currentFile->addError($error, $errorPos); } else if ($content !== 'Squiz Pty Ltd <*****@*****.**>') { $error = 'Expected "Squiz Pty Ltd <*****@*****.**>" for author tag'; $this->currentFile->addError($error, $errorPos); } }*/ }