Adjust PEAR coding standard to our use

- do not require some phpdoc tags
- do not require PHP version to be specified
This commit is contained in:
Michal Čihař 2012-04-26 15:38:57 +02:00
parent 3571184549
commit 749f66de39
4 changed files with 12 additions and 35 deletions

View File

@ -18,8 +18,8 @@ if (class_exists('PHP_CodeSniffer_CommentParser_ClassCommentParser', true) === f
throw new PHP_CodeSniffer_Exception($error);
}
if (class_exists('PEAR_Sniffs_Commenting_FileCommentSniff', true) === false) {
$error = 'Class PEAR_Sniffs_Commenting_FileCommentSniff not found';
if (class_exists('PMAStandard_Sniffs_Commenting_FileCommentSniff', true) === false) {
$error = 'Class PMAStandard_Sniffs_Commenting_FileCommentSniff not found';
throw new PHP_CodeSniffer_Exception($error);
}
@ -46,7 +46,7 @@ if (class_exists('PEAR_Sniffs_Commenting_FileCommentSniff', true) === false) {
* @version Release: 1.3.3
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
class PEAR_Sniffs_Commenting_ClassCommentSniff extends PEAR_Sniffs_Commenting_FileCommentSniff
class PMAStandard_Sniffs_Commenting_ClassCommentSniff extends PMAStandard_Sniffs_Commenting_FileCommentSniff
{

View File

@ -26,7 +26,6 @@ if (class_exists('PHP_CodeSniffer_CommentParser_ClassCommentParser', true) === f
* <li>There is a blank newline after the short description.</li>
* <li>There is a blank newline between the long and short description.</li>
* <li>There is a blank newline between the long description and tags.</li>
* <li>A PHP version is specified.</li>
* <li>Check the order of the tags.</li>
* <li>Check the indentation of each tag.</li>
* <li>Check required and optional tags and the format of their content.</li>
@ -42,7 +41,7 @@ if (class_exists('PHP_CodeSniffer_CommentParser_ClassCommentParser', true) === f
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
class PEAR_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
class PMAStandard_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
{
/**
@ -66,7 +65,7 @@ class PEAR_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
*/
protected $tags = array(
'category' => array(
'required' => true,
'required' => false,
'allow_multiple' => false,
'order_text' => 'precedes @package',
),
@ -81,7 +80,7 @@ class PEAR_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
'order_text' => 'follows @package',
),
'author' => array(
'required' => true,
'required' => false,
'allow_multiple' => true,
'order_text' => 'follows @subpackage (if used) or @package',
),
@ -91,7 +90,7 @@ class PEAR_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
'order_text' => 'follows @author',
),
'license' => array(
'required' => true,
'required' => false,
'allow_multiple' => false,
'order_text' => 'follows @copyright (if used) or @author',
),
@ -101,7 +100,7 @@ class PEAR_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
'order_text' => 'follows @license',
),
'link' => array(
'required' => true,
'required' => false,
'allow_multiple' => true,
'order_text' => 'follows @version',
),
@ -311,9 +310,6 @@ class PEAR_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
}
}
// Check the PHP Version.
$this->processPHPVersion($commentStart, $commentEnd, $long);
// Check each tag.
$this->processTags($commentStart, $commentEnd);
}//end if
@ -321,25 +317,6 @@ class PEAR_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
}//end process()
/**
* Check that the PHP version is specified.
*
* @param int $commentStart Position in the stack where the comment started.
* @param int $commentEnd Position in the stack where the comment ended.
* @param string $commentText The text of the function comment.
*
* @return void
*/
protected function processPHPVersion($commentStart, $commentEnd, $commentText)
{
if (strstr(strtolower($commentText), 'php version') === false) {
$error = 'PHP version not specified';
$this->currentFile->addWarning($error, $commentEnd, 'MissingVersion');
}
}//end processPHPVersion()
/**
* Processes each required or optional tag.
*
@ -350,7 +327,7 @@ class PEAR_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
*/
protected function processTags($commentStart, $commentEnd)
{
$docBlock = (get_class($this) === 'PEAR_Sniffs_Commenting_FileCommentSniff') ? 'file' : 'class';
$docBlock = (get_class($this) === 'PMAStandard_Sniffs_Commenting_FileCommentSniff') ? 'file' : 'class';
$foundTags = $this->commentParser->getTagOrders();
$orderIndex = 0;
$indentation = array();
@ -683,7 +660,7 @@ class PEAR_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
}
} else {
$error = 'Content missing for @author tag in %s comment';
$docBlock = (get_class($this) === 'PEAR_Sniffs_Commenting_FileCommentSniff') ? 'file' : 'class';
$docBlock = (get_class($this) === 'PMAStandard_Sniffs_Commenting_FileCommentSniff') ? 'file' : 'class';
$data = array($docBlock);
$this->currentFile->addError($error, $errorPos, 'EmptyAuthors', $data);
}

View File

@ -44,7 +44,7 @@ if (class_exists('PHP_CodeSniffer_CommentParser_FunctionCommentParser', true) ==
* @version Release: 1.3.3
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
class PEAR_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_Sniff
class PMAStandard_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_Sniff
{
/**

View File

@ -27,7 +27,7 @@
* @version Release: 1.3.3
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
class PEAR_Sniffs_Commenting_InlineCommentSniff implements PHP_CodeSniffer_Sniff
class PMAStandard_Sniffs_Commenting_InlineCommentSniff implements PHP_CodeSniffer_Sniff
{